Skip to content

Commit 6d56287

Browse files
committed
More edits
1 parent 96bbccf commit 6d56287

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3904,14 +3904,14 @@ defmodule Kernel do
39043904
iex> if "truthy value", do: "yes"
39053905
"yes"
39063906
3907-
In the examples above, `"yes"` will be returned because the condition
3908-
evaluates to a truthy value (neither `false` nor `nil`). Otherwise, `nil`
3909-
will be returned:
3907+
In the examples above, the `do` clause is evaluated and `"yes"` will be returned
3908+
because the condition evaluates to a truthy value (neither `false` nor `nil`).
3909+
Otherwise, the clause is not evaluated and `nil` will be returned:
39103910
39113911
iex> if 3 > 5, do: "yes"
39123912
nil
39133913
3914-
iex> if nil, do: "yes"
3914+
iex> if nil, do: IO.puts("this won't be printed")
39153915
nil
39163916
39173917
An `else` option can be given to specify the opposite:
@@ -3929,7 +3929,7 @@ defmodule Kernel do
39293929
...> end
39303930
"yes"
39313931
3932-
Note that `do`-`end` become delimiters. The second example would
3932+
Note that `do`-`end` become delimiters. The third example would
39333933
translate to:
39343934
39353935
iex> if 3 > 5 do
@@ -3957,6 +3957,7 @@ defmodule Kernel do
39573957
39583958
fruits = %{oranges: 3}
39593959
if count = fruits[:apples] do
3960+
# won't be evaluated
39603961
IO.puts(count + 1)
39613962
end
39623963
count # nil

0 commit comments

Comments
 (0)