Skip to content

Commit 10a2f8a

Browse files
committed
Add a note about modules and keywords in is_atom/1
1 parent 160ce8c commit 10a2f8a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,20 +638,24 @@ defmodule Kernel do
638638
@doc """
639639
Returns `true` if `term` is an atom, otherwise returns `false`.
640640
641+
Note `true`, `false`, and `nil` are atoms in Elixir, as well as
642+
module names. Therefore this function will return `true` to all
643+
of those values.
644+
641645
Allowed in guard tests. Inlined by the compiler.
642646
643647
## Examples
644648
645-
iex> is_atom(false)
649+
iex> is_atom(:name)
646650
true
647651
648-
iex> is_atom(:name)
652+
iex> is_atom(false)
649653
true
650654
651655
iex> is_atom(AnAtom)
652656
true
653657
654-
iex> is_atom("true")
658+
iex> is_atom("string")
655659
false
656660
657661
"""

lib/elixir/lib/kernel/utils.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ defmodule Kernel.Utils do
208208

209209
case enforce_keys -- :maps.keys(struct) do
210210
[] ->
211-
# The __struct__ attribute is public and it is used for expansion
212-
# and for loading remote structs.
211+
# The __struct__ attribute is during expansion and for loading remote structs
213212
:ets.insert(set, {:__struct__, struct, nil, []})
214213

215214
# The complete metadata goes into __info__(:struct)

0 commit comments

Comments
 (0)