diff --git a/README.md b/README.md index 2e8a2f4..9fe7060 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/elixir/create-a-list-of-atoms.md b/elixir/create-a-list-of-atoms.md new file mode 100644 index 0000000..8438212 --- /dev/null +++ b/elixir/create-a-list-of-atoms.md @@ -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)