string literal in binary construction

Claes Wikstrom klacke@REDACTED
Thu Jul 13 10:09:37 CEST 2006


Romain Lenglet wrote:
> Vance Shipley wrote:
>> 1> <<"123">>.
> 
> This is syntactic sugar for <<$1, $2, $3>>.
> 
>> <<"123">>
>> 2> String = "123".
>> "123"
>> 3> <<String>>.
>> ** exited: {badarg,[{erl_eval,expr,3}]} **
> 
> Use list_to_binary(String) instead.
> 

Hmmm

<<A:32, String/string, B/binary>>

would certainly be useful (easy to implement too)


/klacke

-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control
cellphone: +46 70 2097763



More information about the erlang-questions mailing list