Problems reading list of maps with lists inside

iex(31)> model
%{
“Year” => [
%{“Label” => “1998 gasoline”, “Value” => “1998-1”},
%{“Label” => “1997 gasoline”, “Value” => “1997-1”},
%{“Label” => “1996 gasoline”, “Value” => “1996-1”},
%{“Label” => “1995 gasoline”, “Value” => “1995-1”},
%{“Label” => “1994 gasoline”, “Value” => “1994-1”},
%{“Label” => “1993 gasoline”, “Value” => “1993-1”},
%{“Label” => “1992 gasoline”, “Value” => “1992-1”},
%{“Label” => “1991 gasoline”, “Value” => “1991-1”}
],
“Models” => [
%{“Label” => “Integra GS 1.8”, “Value” => 1},
%{“Label” => “Legend 3.2/3.5”, “Value” => 2},
%{“Label” => “NSX 3.0”, “Value” => 3}
]
}
iex(32)> [_year, {_key, models}] = model

** (MatchError) no match of right hand side value:…

1 Like

Hi @WilliamJageR, welcome! To enable the broadest range of people to help you on this forum, it would be helpful if you could describe your problem in english.

However based on your code, you’re trying to match a list against a map. You should try:

%{"Modelos" => modelos} = model
models |> IO.inspect
3 Likes

Translation done, sorry about that :wink:

1 Like