Skip to content

Commit 392a2fb

Browse files
committed
Document the break-trigger in h/0
1 parent bcd4b97 commit 392a2fb

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lib/iex/lib/iex/helpers.ex

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule IEx.Helpers do
66
more joyful to work with.
77
88
This message was triggered by invoking the helper
9-
`h()`, usually referred as `h/0` (since it expects 0
9+
`h()`, usually referred to as `h/0` (since it expects 0
1010
arguments).
1111
1212
There are many other helpers available:
@@ -37,6 +37,36 @@ defmodule IEx.Helpers do
3737
h(Enum)
3838
h(Enum.reverse/1)
3939
40+
41+
## A note about expressions in IEx ##
42+
43+
IEx treats incomplete expressions in a special way, allowing one
44+
to spill an expression over multiple lines. For example,
45+
46+
iex(1)> "ab
47+
...(1)> c"
48+
"ab\nc"
49+
50+
In the example above, the shell will be expecting more input until it finds
51+
the closing quote. Sometimes it is not obvious which character the shell is
52+
expecting, and the user may find themselves trapped in the state of
53+
incomplete expression with no ability to terminate it other than by exiting
54+
the shell.
55+
56+
For such cases, there is a special break-trigger ("#!break") that when
57+
encountered on a line by itself will force the shell to break out of any
58+
pending expression and return to its normal state:
59+
60+
iex(1)> ["ab
61+
...(1)> c"
62+
...(1)> "
63+
...(1)> ]
64+
...(1)> #!break
65+
** (TokenMissingError) iex:1: incomplete expression
66+
...
67+
68+
iex(1)>
69+
4070
"""
4171

4272
@doc """

0 commit comments

Comments
 (0)