Different result using io_lib:format under version 21, Is this expected?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Different result using io_lib:format under version 21, Is this expected?

chris casilli
Hello,

A few of my tests started failing when run under the newer versions 21.0.
I wanted to ensure this is expected new behavior, before I modify my code to match new results:

With the previous versions this was the result:
io_lib:format(“~.16B”,[255]).
[“FF”]

This is the current result under the new version 21.0 & 20.0.1
io_lib:format(“~.16B”,[255]).
“FF”

Please let me know if this is expected and the new expected result.

Kind Regards,

Chris Casilli



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Different result using io_lib:format under version 21, Is this expected?

Sölvi Páll Ásgeirsson
Hi Chris

Both are legal return values from io_lib:format/2; it's defined such
that it might return deep lists.

I'd suggest that you flatten the output in your tests and don't rely
on a specific structure.
You can do that by using e.g. the built-in function iolist_to_binary/1
or lists:flatten/1.
However, you do not need to, and should not, flatten the list before
writing it to a file or a socket.

I've found that https://prog21.dadgum.com/70.html explains the concept
quite well.

Regards
Sölvi Páll Á.

On Tue, Jun 26, 2018 at 5:43 PM, chris casilli
<[hidden email]> wrote:

> Hello,
>
> A few of my tests started failing when run under the newer versions 21.0.
> I wanted to ensure this is expected new behavior, before I modify my code to match new results:
>
> With the previous versions this was the result:
> io_lib:format(“~.16B”,[255]).
> [“FF”]
>
> This is the current result under the new version 21.0 & 20.0.1
> io_lib:format(“~.16B”,[255]).
> “FF”
>
> Please let me know if this is expected and the new expected result.
>
> Kind Regards,
>
> Chris Casilli
>
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions