Sigils
import IEx.Helpers
Uses
["one", "two", "three"]
~w[one two three four]
~w(one two three four)
~w{one two three four}
~w"one two three four"
~w[one two three four]a
~w[one two three four]c
~w[one two three four]s # default
~s{a string with "a string"}
Implementation
Available
sigil_w(<<"one two three">>, 'a')
<<"test">> == "test"
exports Kernel
:macros
|> Kernel.__info__()
|> Enum.map(fn {name, _arity} -> to_string(name) end)
|> Enum.filter(fn name -> String.contains?(name, "sigil_") end)
h sigil_C/2
value = "four"
~W[one two three #{value}]
Defining
defmodule Numbers do
def sigil_i(str, _mod), do: String.to_integer(str)
end
import Numbers
sigil_i("23", "")
~i(00067)