Implementing Ruby's lonely operator using Elixir's custom infix function
iex> import ViewHelper
iex> user = %{name: "Imran", address: %{postcode: 33160}}
iex> user ~> :name
# "Imran"
iex> user ~> :address ~> :postcode
# 33160
iex> user ~> :address ~> :country
# nil
Update
Just found out from benwilson that [] implements the access protocol, so it would return nil even when accessing from nil.
Using access:
iex> user = %{name: "imran"}
iex> user[:name][:address][:postcode]
# nil
OR if you want the same syntax as above
iex> user |> Access.get(:name) |> Access.get(:postcode)
# nil
OR use get_in DUH!
Rewrote to just use the Access module
Update 2
Use back old implementation because Access protocol is not implemented on struct unless explicitly derived. Rightly so.