Operators

Operators are applied to expressions using post-fix notation with a period (.) as the separator. For example, if a is a string, the lc() operator, which creates a new string with the case of all characters in a lowered, is applied to a as follows:

a.lc()

Operators can be chained. The following expression splits a into an array and then calculates the length of the resulting array:

a.split(re#;#).length()

Operators are syntactic sugar for normal function application. The left hand of the period (.) is inserted as the first argument of the function call. For example:

foo = function (self, arg1, arg2) {
  // `self` is the left hand side of `.`
}

// then use it
"something".foo(1, 2)
// which is the same as
foo("something", 1, 2)

// Another example:
a.split(re#;#).length()
// is the same as
length(split(a, re#;#))

The following sections describe operators currently available. They are organized based on the kind of value on which they operate.

Copyright Picolabs | Licensed under Creative Commons.