1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +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

@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
For a steady stream of TILs from a variety of rocketeers, checkout
[til.hashrocket.com](https://til.hashrocket.com/).
_532 TILs and counting..._
_533 TILs and counting..._
---
@@ -100,6 +100,7 @@ _532 TILs and counting..._
- [Compute md5 Digest Of A String](elixir/compute-md5-digest-of-a-string.md)
- [Counting Records With Ecto](elixir/counting-records-with-ecto.md)
- [Create A Date With The Date Sigil](elixir/create-a-date-with-the-date-sigil.md)
- [Create A List Of Atoms](elixir/create-a-list-of-atoms.md)
- [Creating A PID](elixir/creating-a-pid.md)
- [Creating Indexes With Ecto](elixir/creating-indexes-with-ecto.md)
- [Defining Multiple Clauses In An Anonymous Function](elixir/defining-multiple-clauses-in-an-anonymous-function.md)

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)