Carapace

The Dot Operator

Properties and methods of an object use the dot operator whose name is . ie. a single full-stop.

Suppose we have an object obj which supports an integer property called size. Using prefix notation, this would be done as follows:

    ( . obj size )
Further, if we wanted to convert the integer to a string, we could then use the string method as follows:
    ( . ( . obj size) string )
Since objects are used a lot within Carapace script, this all gets a bit cumbersome.

We therefore use the following syntax for the dot operator:

    (obj.size)
and to turn this into a string, both the following are allowed:
    ((obj.size).string)
    (obj.size.string)
The dot operator is called an infix operator since it comes in-between its arguments.

The dot operator is the only infix operator within Carapace.

The dot operator is used for the following tasks:


Contents Index Current topic: objects Related topics: functions