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

Junior White <>
Thu Oct 11 06:20:28 CEST 2012


hi,
   This behave makes me confused too.

On Mon, Oct 1, 2012 at 4:46 PM, Jesse Gumm <> wrote:

> Hi,
>
> You just need to convert List to a binary first with list_to_binary.
>
> The <<"something">> syntax is just a friendly way to make binary literals.
> But it does not perform automatic casting of lists.
>
> Further, the extra << >> you're wrapping around "-" is unnecessary.
>
> Example:
>
> > L = "123456",
> > B = list_to_binary(L),
> > <<B/binary,"-">>.
>
> Will yield:
>
> <<"123456-">>
>
> Hope that helps.
>
> Take it easy,
>
> -Jesse
>
> --
> Jesse Gumm
> Owner, Sigma Star Systems
> 414.940.4866 || sigma-star.com || @jessegumm
> On Oct 1, 2012 3: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
>>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121011/2ac79665/attachment.html>


More information about the erlang-questions mailing list