tompave
tompave

Reputation: 12427

"%w(foo, bar)" constructs in Elixir

I stumbled upon the %w(foo, bar) construct in Elixir.

I can't find any reference to it in the current docs, and google is not helping either.
It looks like it was part of the language in 2013.

Can anyone point me to the documentation and maybe show an example?

Upvotes: 1

Views: 204

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176522

Elixir provides sigils. As explained in the docs, sigils are one of the mechanisms provided by the language for working with textual representations.

Prior to v1, Elixir sigil syntax was very similar to Ruby. Specifically, the following line:

%w( foo bar )

produced a word list.

The syntax of sigils was changed in 2014 and it is now prefixed by ~ instead of %:

~w( foo bar )

Upvotes: 5

Related Questions