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

Joe Armstrong <>
Thu Oct 11 19:54:07 CEST 2012


1> L = "hello".
"hello"
2> << L, " world" >>.
** exception error: bad argument
3>
3> B = <<"hello">>.
<<"hello">>
4> << B, " world" >>.
** exception error: bad argument

5> << B/binary, " world" >>.
<<"hello world">>

<< X1 X2 ... >>   constructs a binary. The X's can be literal strings
"....." or Var/Descriptor.

Its described in section 7.16 of the erlang reference manual

 http://www.erlang.org/doc/reference_manual/expressions.html#id77949

Cheers

/Joe


On Mon, Oct 1, 2012 at 10:11 AM, Chris Cook <> 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
> 
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list