Last active
August 29, 2015 14:05
-
-
Save cheeyeo/d090a4400e00535082c5 to your computer and use it in GitHub Desktop.
Try elixir code samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Expressions | |
iex> 40 + 2 | |
iex> "hello" <> " world" | |
#Basic types | |
iex> 1 # integer | |
iex> 0x1F # integer | |
iex> 1.0 # float | |
iex> :atom # atom / symbol | |
iex> "elixir" # string | |
iex> [1, 2, 3] # list | |
iex> {1, 2, 3} # tuple | |
# Basic arithmetic | |
iex> 1 + 2 | |
3 | |
iex> 5 * 5 | |
25 | |
iex> 10 / 2 | |
5.0 | |
#String interpolation | |
iex> "hellö #{:world}" | |
"hellö world" | |
#Tuples | |
iex> {:ok, "hello"} | |
{:ok, "hello"} | |
iex> tuple_size {:ok, "hello"} | |
2 | |
#List | |
iex> list = [1,2,3] | |
[1,2,3] | |
iex> [0] ++ list | |
[0, 1, 2, 3] | |
iex> list ++ [4] | |
[1, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment