EN - Documentation on terminal iex

EN - Documentation on terminal iex

2020, Apr 29    

To enter on a elixir terminal you can run:

  $ iex

Then, to show documentation of a specific function you can use h like that example:

  $ h round/1

  # =>                              def round(number)                                

  # => @spec round(number()) :: integer()

  # => guard: true

  # => Rounds a number to the nearest integer.

  # => If the number is equidistant to the two nearest integers, rounds away from zero.

  # => Allowed in guard tests. Inlined by the compiler.
  ## Examples

      iex> round(5.6)
      # => 6
      
      iex> round(5.2)
      # => 5
      
      iex> round(-9.9)
      # => -10
      
      iex> round(-9)
      # => -9
      
      iex> round(2.5)
      # => 3
      
      iex> round(-2.5)
      # => -3

In this case, round/1 is a function called round that recieves an argument/arity.