[erlang-questions] The way of accessing record's attributes.

Stanislaw Klekot erlang.org@REDACTED
Tue Nov 8 15:30:08 CET 2016


On Tue, Nov 08, 2016 at 02:12:35PM +0100, Alex Feng wrote:
> Does anyone know why erlang has to attach the record's name to be able to
> access an attribute ?
> I don't understand, for example, the record "#robot" has been assigned to
> variable "Crusher", why do we have to use  "Crusher#robot.hobbies" instead
> of "Crusher.hobbies" ?

Records are syntax sugar for tuples. Compiler doesn't know what kind of
value is in `Crusher' (maybe some different record) and what are the
field names (which is more important), so you need to specify
appropriate record name yourself.

-- 
Stanislaw Klekot



More information about the erlang-questions mailing list