晴耕雨読

working in the fields on fine days and reading books on rainy days

Elixir Typespecs

Elixir の型一覧

Atom, Boolean, String, Integer, Range, Float, List, Keyword List, Map, Tuple, Function

  • Atom
    • :foo
  • Boolean
    • true
    • false
  • String
    • "foo"
  • Integer
    • 123
  • Range
    • 1..10
  • Float
    • 3.14
  • List
    • [1, 2, 3]
    • []
  • Keyword
    • [key: "value"]
  • Map
    • %{key: "value"}
    • %{3.14 => "π"}
    • %{}
  • Struct
    • %SomeStruct{key: "value"}
  • Tuple
    • {:ok, type}
    • {x, y, z} = {1, 2, 3}
  • Binary
    • <<1, 2, 3>>
    • <<0, "foo"::utf8>>
  • Bitstring
    • <<0, 1::size(7)>>
  • Function
    • fn -> :ok end
    • fn ... -> :ok end
    • fn arg1, arg2 -> :ok end
    • &(&1)
    • &(&1 + &2)
    • &String.trim/1
    • &String.replace(&1, ~r/\s+/, "")