Skip to content

Commit 307d263

Browse files
mfrascajosevalim
authored andcommitted
Make the information about the h helper more prominent (elixir-lang#1264)
1 parent 269c9dc commit 307d263

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

getting-started/basic-types.markdown

+12-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,21 @@ iex> trunc(3.58)
7777
3
7878
```
7979

80-
## Identifying functions
80+
## Identifying functions and documentation
8181

8282
Functions in Elixir are identified by both their name and their arity. The arity of a function describes the number of arguments that the function takes. From this point on we will use both the function name and its arity to describe functions throughout the documentation. `round/1` identifies the function which is named `round` and takes `1` argument, whereas `round/2` identifies a different (nonexistent) function with the same name but with an arity of `2`.
8383

84+
We can also use this syntax to access documentation. The Elixir shell defines the `h` function, which you can use to access documentation for any function. For example, typing `h round/1` is going to print the documentation for the `round/1` function:
85+
86+
```iex
87+
iex> h round/1
88+
def round()
89+
90+
Rounds a number to the nearest integer.
91+
```
92+
93+
It also works with operators and other constructs (try `h +/2`). Invoking `h` without arguments displays the documentation for `IEx.Helpers`, which is where `h` and other functionality is defined.
94+
8495
## Booleans
8596

8697
Elixir supports `true` and `false` as booleans:
@@ -103,8 +114,6 @@ false
103114

104115
You can also use `is_integer/1`, `is_float/1` or `is_number/1` to check, respectively, if an argument is an integer, a float, or either.
105116

106-
> Note: At any moment you can type `h()` in the shell to print information on how to use the shell. The `h` helper can also be used to access documentation for any function. For example, typing `h is_integer/1` is going to print the documentation for the `is_integer/1` function. It also works with operators and other constructs (try `h ==/2`).
107-
108117
## Atoms
109118

110119
An atom is a constant whose name is its own value. Some other languages call these symbols:

0 commit comments

Comments
 (0)