mirror of
https://github.com/jbranchaud/til
synced 2026-01-05 08:08:02 +00:00
Add Create A List Of Atoms as an elixir til
This commit is contained in:
19
elixir/create-a-list-of-atoms.md
Normal file
19
elixir/create-a-list-of-atoms.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Create A List Of Atoms
|
||||
|
||||
The `~w` sigil makes it easy to create a word list -- a list of strings --
|
||||
where each word is separated by a space.
|
||||
|
||||
```elixir
|
||||
> ~w(bulbasaur charmander squirtle)
|
||||
["bulbasaur", "charmander", "squirtle"]
|
||||
```
|
||||
|
||||
By appending an `a` onto that sigil construct, you are instructing Elixir
|
||||
that you would instead like a list of atoms.
|
||||
|
||||
```elixir
|
||||
> ~w(bulbasaur charmander squirtle)a
|
||||
[:bulbasaur, :charmander, :squirtle]
|
||||
```
|
||||
|
||||
[source](http://elixir-lang.org/getting-started/sigils.html#strings)
|
||||
Reference in New Issue
Block a user