Sigils in Elixir
In Elixir, there's strings "hi"
and charlists 'hi'
.
You can also use the ~c sigil to denote a charlist -
~c"hi there"
There's also a word list sigil ~w
which behaves similarly to %w
in Ruby. It constructs a list of words -
~w(blue red green)
=> ["blue", "red", "green"]
Also worth mentioning, the ~r
sigil for regexes -
"foo" =~ ~r"hashrocket"
=> false
"hashrocket" =~ ~r/hashrocket/
=> true
There's many other sigils in Phoenix and Elixir. Be sure to check out the docs!
h/t to Jack Rosa
https://hexdocs.pm/elixir/sigils.html
Tweet