1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 15:48:01 +00:00

Add Range Into List Using Comprehensions as an elixir til

This commit is contained in:
jbranchaud
2016-12-11 17:10:35 -06:00
parent f31ed61960
commit a7e5b1d8f0
2 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
# Range Into List Using Comprehensions
Using an _identity_ comprehension and the `:into` option, we can easily
convert a range into a list.
```elixir
> for x <- 1..10, into: [], do: x
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
```
Check out [the docs for the `:into`
option](http://elixir-lang.org/getting-started/comprehensions.html#the-into-option)
for more details.