File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -467,32 +467,36 @@ defmodule IO do
467
467
468
468
## Examples
469
469
470
+ The following code:
471
+
470
472
IO.inspect(<<0, 1, 2>>, width: 40)
471
473
472
474
Prints:
473
475
474
476
<<0, 1, 2>>
475
477
476
- We can use the `:label` option to decorate the output:
478
+ You can use the `:label` option to decorate the output:
477
479
478
480
IO.inspect(1..100, label: "a wonderful range")
479
481
480
482
Prints:
481
483
482
484
a wonderful range: 1..100
483
485
484
- The `:label` option is especially useful with pipelines:
486
+ Inspect truncates large inputs by default. The `:printable_limit` controls
487
+ the limit for strings and other string-like constructs (such as charlists):
485
488
486
- [1, 2, 3]
487
- |> IO.inspect(label: "before")
488
- |> Enum.map(&(&1 * 2))
489
- |> IO.inspect(label: "after")
490
- |> Enum.sum()
489
+ "abc"
490
+ |> String.duplicate(9001)
491
+ |> IO.inspect(printable_limit: :infinity)
491
492
492
- Prints:
493
+ For containers such as lists, maps, and tuples, the number of entries
494
+ is managed by the `:limit` option:
493
495
494
- before: [1, 2, 3]
495
- after: [2, 4, 6]
496
+ 1..100
497
+ |> Enum.map(& {&1, &1})
498
+ |> Enum.into(%{})
499
+ |> IO.inspect(limit: :infinity)
496
500
497
501
"""
498
502
@ spec inspect ( item , inspect_opts ) :: item when item: var
You can’t perform that action at this time.
0 commit comments