Elixir's get nexted key and value in nested Map

Elixir’s get nexted key and value in nested Map

Although it is not super intuitive since it does not belong to the Map module, Elixir has a built in get_in function which is used to retrieve a nested value in nested maps using an array of keys.

movie_map = %{ movie: %{ title: "Deadpool"} }
title = get_in(movie_map, [:movie, :title])
=> nil
# When value is not present, returns nil
description = get_in(movie_map, [:movie, :description])
=> nil
director_name = get_in(movie_map, [:movie, :cast, :director, :first_name])
=> nil