IEx Commands

From Elixir Wiki
Jump to navigation Jump to search

IEx Commands[edit]

Template:Toc

IEx (Interactive Elixir) is an interactive shell used for running Elixir code, debugging, and experimenting with the language. It provides a set of commands that enhance the user experience and enable efficient development. This article covers the commonly used IEx commands and their functionalities.

h/1[edit]

The `h/1` command allows you to access the documentation for a given Elixir module, function, or macro. It displays information about the provided argument, including its name, parameters, and description.

Syntax: `h(argument)`

Example: ``` iex> h(Enum.map) ```

i/1[edit]

The `i/1` command is used to inspect an Elixir expression, providing detailed information about its type, value, and other relevant data.

Syntax: `i(expression)`

Example: ``` iex> i("Hello, World!") ```

c/1[edit]

The `c/1` command compiles an Elixir source file or a list of files into bytecode, making it ready for execution.

Syntax: `c(file | [files], options \\ [])`

Example: ``` iex> c("my_file.ex") ```

r/0[edit]

The `r/0` command reloads the previously compiled module(s) during the current IEx session, allowing you to apply any changes made to the corresponding source code without restarting IEx.

Syntax: `r()`

Example: ``` iex> r() ```

t/1[edit]

The `t/1` command is used to retrieve information about a given Elixir data type, including its name, implementation, and associated protocols.

Syntax: `t(type)`

Example: ``` iex> t(List) ```

L/0[edit]

The `L/0` command lists all the modules that are currently loaded in the current IEx session.

Syntax: `L()`

Example: ``` iex> L() ```

v/0[edit]

The `v/0` command displays the currently defined local variables along with their respective values in the current IEx session.

Syntax: `v()`

Example: ``` iex> v() ```

h/0[edit]

The `h/0` command displays general information and a list of available IEx specific commands.

Syntax: `h()`

Example: ``` iex> h() ```

q/0[edit]

The `q/0` command is used to quit the current IEx session and return to the shell.

Syntax: `q()`

Example: ``` iex> q() ```

You can find more information about IEx and its commands in the Elixir official documentation.

Template:Stub