@@ -552,7 +552,8 @@ defmodule Code do
552552 all imports, requires and aliases defined in the current environment
553553 will be automatically carried over:
554554
555- iex> {result, binding} = Code.eval_string("a + b", [a: 1, b: 2], __ENV__)
555+ iex> require Integer
556+ iex> {result, binding} = Code.eval_string("if Integer.is_odd(a), do: a + b", [a: 1, b: 2], __ENV__)
556557 iex> result
557558 3
558559 iex> Enum.sort(binding)
@@ -975,12 +976,18 @@ defmodule Code do
975976 the code representation (AST). While the formatter can preserve code
976977 comments between expressions and function arguments, the formatter
977978 cannot currently preserve them around operators. For example, the following
978- code will move the code comments to before the operator usage :
979+ code:
979980
980981 foo() ||
981982 # also check for bar
982983 bar()
983984
985+ will move the code comments to before the operator usage:
986+
987+ # also check for bar
988+ foo() ||
989+ bar()
990+
984991 In some situations, code comments can be seen as ambiguous by the formatter.
985992 For example, the comment in the anonymous function below
986993
@@ -1247,6 +1254,14 @@ defmodule Code do
12471254 * atoms used to represent single-letter sigils like `:sigil_X`
12481255 (but multi-letter sigils like `:sigil_XYZ` are encoded).
12491256
1257+ ## Examples
1258+
1259+ iex> Code.string_to_quoted("1 + 3")
1260+ {:ok, {:+, [line: 1], [1, 3]}}
1261+
1262+ iex> Code.string_to_quoted("1 \ 3")
1263+ {:error, {[line: 1, column: 4], "syntax error before: ", "\" 3\" "}}
1264+
12501265 """
12511266 @ spec string_to_quoted ( List.Chars . t ( ) , keyword ) ::
12521267 { :ok , Macro . t ( ) } | { :error , { location :: keyword , binary | { binary , binary } , binary } }
@@ -2085,7 +2100,7 @@ defmodule Code do
20852100
20862101 ## Examples
20872102
2088- iex> Code.loaded?(Atom )
2103+ iex> Code.loaded?(String )
20892104 true
20902105
20912106 iex> Code.loaded?(NotYetLoaded)
0 commit comments