Enum.into alternatives and matching structs

2022/08/22

Map.new/2

Instead of leveraging Enum.into/2 you can use Map.new/2 with an enumerable collection.

Pattern matching structs

I learned that you can pattern match structs.

def new(%_{} = struct), do: new_from_enum(struct)

References

  1. Github usage of of pattern matching a struct
  2. Reddit thread that introduced me to the ideas
  3. Map.new/2