Как я могу обновить reserved.information.player_id с 8ffb69ce-9a6b-44a6-8e8f-c069235d2d31 до 12345?
defmodule Statcasters.Questions.Reserved do
defstruct information: %{}, inputs: []
end
defmodule My do
def go do
map = %{
__meta__: "hello world",
__struct__: "boo hoo",
active: true,
description: "player points",
id: 118,
inserted_at: ~N[2018-08-26 19:48:22.501445],
reserved: %Statcasters.Questions.Reserved{
information: %{
game_id: "b796cbe9-0bb6-4aaf-98b0-5da81c337208",
player_id: "8ffb69ce-9a6b-44a6-8e8f-c069235d2d31",
player_name: "Lebron James"
},
inputs: [%{label: "Player Points", type: "text"}]
},
type: "NBA",
updated_at: ~N[2018-08-26 19:48:22.504193]
}
put_in(map.reserved.information.player_id, 12345)
end
end
В iex:
~/elixir_programs$ iex
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (1.6.6) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> c "my.exs"
[My, Statcasters.Questions.Reserved]
iex(2)> My.go
%{
__meta__: "hello world",
__struct__: "boo hoo",
active: true,
description: "player points",
id: 118,
inserted_at: ~N[2018-08-26 19:48:22.501445],
reserved: %Statcasters.Questions.Reserved{
information: %{
game_id: "b796cbe9-0bb6-4aaf-98b0-5da81c337208",
player_id: 12345,
player_name: "Lebron James"
},
inputs: [%{label: "Player Points", type: "text"}]
},
type: "NBA",
updated_at: ~N[2018-08-26 19:48:22.504193]
}
iex(3)>