[erlang-questions] Bad Argument, (Bug or something I'm missing).

Lukas Larsson lukas@REDACTED
Mon Oct 1 10:43:53 CEST 2012


Hi,

If you just do

2> L = "a",<<L>>.
** exception error: bad argument

You get the same behaviour. When you do <<"a">> it is just syntactic
sugar for << <<97>>/binary >>. However when passing the value as a
variable you do not get the syntactic sugar help so you have to do
this:

3> L = "a",<<(list_to_binary(L))/binary>>.
<<"a">>

or something to that effect to get the correct result. Hope that makes sense.

Lukas

On Mon, Oct 1, 2012 at 10:11 AM, Chris Cook <cookchrisd@REDACTED> wrote:
> Morning list,
>
> I have,
>
> Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.9.1  (abort with ^G)
> 1> List = "89234789234jhk2hk234892789fauky324978".
> "89234789234jhk2hk234892789fauky324978"
> 2> <<List, <<"-">>/binary>>.
> ** exception error: bad argument
>
> But when I write it as this,
>
> 3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
> <<"89234789234jhk2hk234892789fauky324978-">>
>
> I get the result I expected to get from the above 1 & 2. Could someone
> please explain what is going wrong and why, because I'm very confused
> with it.
>
> Regards
>
> Chris Cook.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list