Skip to content

Commit 041c417

Browse files
whatyouhidejosevalim
authored andcommitted
Fix the output of some examples in the "Case, cond and if chapter" (elixir-lang#729)
1 parent b4e58bb commit 041c417

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: getting-started/case-cond-and-if.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ One thing to keep in mind when using `do/end` blocks is they are always bound to
251251
iex> is_number if true do
252252
...> 1 + 2
253253
...> end
254-
** (RuntimeError) undefined function: if/1
254+
** (CompileError) undefined function: is_number/2
255255
```
256256

257257
Would be parsed as:
@@ -260,10 +260,10 @@ Would be parsed as:
260260
iex> is_number(if true) do
261261
...> 1 + 2
262262
...> end
263-
** (RuntimeError) undefined function: if/1
263+
** (CompileError) undefined function: is_number/2
264264
```
265265

266-
Which leads to an undefined function error as Elixir attempts to invoke `if/1`. Adding explicit parentheses is enough to resolve the ambiguity:
266+
which leads to an undefined function error as Elixir attempts to invoke `is_number/1`, but passing it *two* arguments (the `if true` expression - which would throw an undefined function error itself as `if` needs a second argument, the `do/end` block - and the `do/end` block). Adding explicit parentheses is enough to resolve the ambiguity:
267267

268268
```iex
269269
iex> is_number(if true do

0 commit comments

Comments
 (0)