[erlang-questions] json to map

Adam Krupicka akrupicka@REDACTED
Fri Aug 28 21:29:58 CEST 2015


Excerpts from Roelof Wobben's message of 2015-08-28 21:20:51 +0200:
> 
> 7> c(time_parser). {ok,time_parser}
> 8> time_parser:tokens([10]).
> ** exception error: no function clause matching time_parser:tokens("\n") 
> (time_parser.erl, line 5)
> 
> where do the /n come from ?

Hi! 10 is the decimal ASCII code for the newline character. This is how
strings are actually usually represented in Erlang: a list of code
points.

If you want to have the parser parse the integer 10, you probably
need to supply it as a string:

9> time_parser:tokens("10").

"10" is in fact syntax sugar for [$1, $0]. The dollar character($)
followed by a character is evaluated to the numerical value of the
character. For example:

1> $\n.
10


Cheers,
A. K.




More information about the erlang-questions mailing list