Elixir Data Types Summary

  • Numbers: Integers and Floats
  • Atoms: :named_constant
  • Binaries: strings are binaries. <<104>> is “h”
  • Maps: %{key: value}. Can use strings or atoms for keys. But only atoms allow map.key; else use map[key]
  • Tuples: {value,value…}. To access – elem(tuple, 0). To add: put_elem(tuple, 0, “value”)
  • Lists: [value, value…]
  • Functions: fn(args) -> … end. To call: fn.(args)
  • Character Lists: ‘h’ is [104]
  • Keyword Lists: [{:atom, value}…] == [atom: “value”,…]
  • Structs: %{key: value}
  • Range: 0..42
  • Regex: ~r/pattern/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.