1
0
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:
jbranchaud
2017-05-22 10:04:57 -05:00
parent d92344b233
commit 8b1c3dacd6
2 changed files with 21 additions and 1 deletions

View 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)