-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enum.chunk_every/2 strange results #7260
Comments
note:
so nothing to do with chunk_every. Elixir attempts to print this as a list of characters, see |
Good to know...but should not IO.inspect correctly serialize to string? How
can I print it correctly then ?
2018-01-26 10:43 GMT+01:00 Wojtek Mach <notifications@github.com>:
… note:
iex> [[9],[9], [1], [0], [0]]
['\t', '\t', [1], [0], [0]]
iex> [9]
'\t'
so nothing to do with chunk_every. Elixir attempts to print this as a list
of characters, see iex> i [9] for more information.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7260 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANsahC0kiFrJKXg7XzIK8oGj0pixUdeks5tOZ5agaJpZM4RuD2Z>
.
|
note this prints what you'd expect, but returns the default representation. If you need to return a string you can do:
This is documented in https://hexdocs.pm/elixir/IO.html#inspect/2, https://hexdocs.pm/elixir/Inspect.Opts.html |
See a good explanation here https://github.com/elixir-lang/elixir/wiki/FAQ#4-why-is-my-list-of-integers-printed-as-a-string For the reasons behind this design, look at this mailing list thread https://groups.google.com/forum/#!msg/elixir-lang-talk/0xxH9HxdQnU/LHgK8elhEQAJ |
Thanks alot! Please close the ticket.
2018-01-26 10:56 GMT+01:00 Michał Muskała <notifications@github.com>:
… See a good explanation here https://github.com/elixir-
lang/elixir/wiki/FAQ#4-why-is-my-list-of-integers-printed-as-a-string For
the reasons behind this design, look at this mailing list thread
https://groups.google.com/forum/#!msg/elixir-lang-talk/
0xxH9HxdQnU/LHgK8elhEQAJ
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7260 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANsav95IiluCKsWLPPTYANDgr2vUF_wks5tOaFMgaJpZM4RuD2Z>
.
|
Environment
Elixir 1.7.0-dev (97cf609) (compiled with OTP 20)
Current behavior
x = Enum.chunk_every([9, 9, 1, 0, 0], 1)
IO.inspect(x)
['\t', '\t', [1], [0], [0]]
Expected behavior
[[9],[9], [1], [0], [0]]
The text was updated successfully, but these errors were encountered: