mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Create A List Of Atoms as an elixir til
This commit is contained in:
@@ -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)
|
||||
|
||||
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