Tutorial by Examples

iex(1)> recompile Compiling 1 file (.ex) :ok
iex(1)> h List.last def last(list) Returns the last element in list or nil if list is empty. Examples ┃ iex> List.last([]) ┃ nil ┃ ┃ iex> List.last([1]) ┃ 1 ┃ ┃ iex> List.last([1, 2, 3]) ┃ 3
iex(1)> 1 + 1 2 iex(2)> v 2 iex(3)> 1 + v 3 See also: Get the value of a row with `v`
iex(1)> a = 10 10 iex(2)> b = 20 20 iex(3)> a + b 30 You can get a specific row passing the index of the row: iex(4)> v(3) 30 You can also specify an index relative to the current row: iex(5)> v(-1) # Retrieves value of row (5-1) -> 4 30 iex(6)> v(-5) # Retrieves...
Use Ctrl + C, Ctrl + C to exit iex(1)> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution Use Ctrl+ \ to immediately exit
iex(1)> i :ok Term :ok Data type Atom Reference modules Atom iex(2)> x = "mystring" "mystring" iex(3)> i x Term "mystring" Data type BitString Byte size 8 Description This is a string: a UTF-8 encoded binary. It's printed surround...
This is useful when you didn't store the PID from a previous command iex(1)> self() #PID<0.138.0> iex(2)> pid("0.138.0") #PID<0.138.0> iex(3)> pid(0, 138, 0) #PID<0.138.0>
If you put your commonly used aliases into an .iex.exs file at the root of your app, IEx will load them for you on startup. alias App.{User, Repo}
By default, user input history in IEx do not persist across different sessions. erlang-history adds history support to both the Erlang shell and IEx: git clone [email protected]:ferd/erlang-history.git cd erlang-history sudo make install You can now access your previous inputs using the up and d...
Sometimes you might accidentally run something in the shell that ends up waiting forever, and thus blocking the shell: iex(2)> receive do _ -> :stuck end In that case, press Ctrl-g. You'll see: User switch command Enter these commands in order: k (to kill the shell process) s (to st...
When you have entered something into IEx which expects a completion, such as a multiline string, IEx will change the prompt to indicate that it is waiting for you finish by changing the prompt to have an ellipsis (...) rather than iex. If you find that IEx is waiting for you to finish an expression...
If you have an elixir file; a script or a module and want to load it into the current IEx session, you can use the c/1 method: iex(1)> c "lib/utils.ex" iex(2)> Utils.some_method This will compile and load the module in IEx, and you'll be able to call all of it's public methods. ...

Page 1 of 1