Maps Mapping

The syntax of Maps in Hamler is the same as Erlang. The differences are listed below:

  • The keys of a Map must have the same type in Hamler;
  • The values of a Map must have the same type in Hamler;
  • The syntax #{k := v} is only used for map pattern matching.

Maps in Hamler:

  1. -- New map, values and keys must have the same type.
  2. m = #{:foo => "foo", :bar => "bar"}
  3. -- Pattern matching
  4. #{:foo := a, :bar := b} = m
  5. a :: String -- "foo"
  6. b :: String -- "bar"

Maps in Erlang:

  1. %% Create a map
  2. M = #{foo => "foo", bar => "bar"}
  3. %% Pattern matching
  4. #{foo := A, bar := B} = M.
  5. A %% "foo"
  6. B %% "bar"