Skip to content

Commit 345ce9c

Browse files
committed
Improve style of examples in Kernel.SpecialForms
1 parent 9c734ac commit 345ce9c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/elixir/lib/kernel/special_forms.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ defmodule Kernel.SpecialForms do
222222
iex> x = 1
223223
iex> <<x::8>> == <<x::size(8)>>
224224
true
225-
iex> <<x::8 * 4>> == <<x::size(8)-unit(4)>>
225+
iex> <<x::8*4>> == <<x::size(8)-unit(4)>>
226226
true
227227
228228
This syntax reflects the fact the effective size is given by
@@ -293,7 +293,7 @@ defmodule Kernel.SpecialForms do
293293
294294
defmodule ImageTyper
295295
@png_signature <<137::size(8), 80::size(8), 78::size(8), 71::size(8),
296-
13::size(8), 10::size(8), 26::size(8), 10::size(8)>>
296+
13::size(8), 10::size(8), 26::size(8), 10::size(8)>>
297297
@jpg_signature <<255::size(8), 216::size(8)>>
298298
299299
def type(<<@png_signature, rest::binary>>), do: :png
@@ -1241,7 +1241,7 @@ defmodule Kernel.SpecialForms do
12411241
[2, 4, 6, 8]
12421242
12431243
# A comprehension with two generators
1244-
iex> for x <- [1, 2], y <- [2, 3], do: x*y
1244+
iex> for x <- [1, 2], y <- [2, 3], do: x * y
12451245
[2, 3, 4, 6]
12461246
12471247
Filters can also be given:
@@ -1263,7 +1263,7 @@ defmodule Kernel.SpecialForms do
12631263
need to organize bitstring streams:
12641264
12651265
iex> pixels = <<213, 45, 132, 64, 76, 32, 76, 0, 0, 234, 32, 15>>
1266-
iex> for <<r::8, g::8, b::8 <- pixels >>, do: {r, g, b}
1266+
iex> for <<r::8, g::8, b::8 <- pixels>>, do: {r, g, b}
12671267
[{213, 45, 132}, {64, 76, 32}, {76, 0, 0}, {234, 32, 15}]
12681268
12691269
Variable assignments inside the comprehension, be it in generators,
@@ -1301,7 +1301,7 @@ defmodule Kernel.SpecialForms do
13011301
iex> opts = %{width: 10, height: 15}
13021302
iex> with {:ok, width} <- Map.fetch(opts, :width),
13031303
...> {:ok, height} <- Map.fetch(opts, :height),
1304-
...> do: {:ok, width * height}
1304+
...> do: {:ok, width * height}
13051305
{:ok, 150}
13061306
13071307
If all clauses match, the `do` block is executed, returning its result.
@@ -1310,14 +1310,14 @@ defmodule Kernel.SpecialForms do
13101310
iex> opts = %{width: 10}
13111311
iex> with {:ok, width} <- Map.fetch(opts, :width),
13121312
...> {:ok, height} <- Map.fetch(opts, :height),
1313-
...> do: {:ok, width * height}
1313+
...> do: {:ok, width * height}
13141314
:error
13151315
13161316
Guards can be used in patterns as well:
13171317
13181318
iex> users = %{"melany" => "guest", "bob" => :admin}
13191319
iex> with {:ok, role} when not is_binary(role) <- Map.fetch(users, "bob"),
1320-
...> do: {:ok, to_string(role)}
1320+
...> do: {:ok, to_string(role)}
13211321
{:ok, "admin"}
13221322
13231323
As in `for/1`, variables bound inside `with/1` won't leak;
@@ -1328,7 +1328,7 @@ defmodule Kernel.SpecialForms do
13281328
iex> with {:ok, width} <- Map.fetch(opts, :width),
13291329
...> double_width = width * 2,
13301330
...> {:ok, height} <- Map.fetch(opts, :height),
1331-
...> do: {:ok, double_width * height}
1331+
...> do: {:ok, double_width * height}
13321332
{:ok, 300}
13331333
iex> width
13341334
nil

0 commit comments

Comments
 (0)