You can define a String using “,

Name = “Simone”.

Note: You have to use double quotes, not single ones!

A string in Erlang is just a List of integer that represent characters that compose the string you defined.
If we try to do:

[Head | RemainingString] = Name.

We will get Head -> 83 (the ‘S’) and RemainingString -> “imone”.

How to know that 83 means ‘S’? You can get $<letter>. to see the value, for example:

$S. -> 83 (so we know that 83 means ‘S’)

So using this thing we can compose a list of integer (representing letters) and create a string like:

[$S, $i, $m, $o, $n, $e]. -> “Simone”

Note: these values are related to Latin-1 (ISO-8859-1) character codes!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: