Expressions

literals
A number of literals are supported:

  • Strings: "This is a string"
  • Ints: 22
  • Float: 8.3
  • Boolean: true/false
  • List: [<expression>, <expression>, ...]
  • Empty list: List<Int>()
  • Set: {<expression>, <expression>, ...}
  • Empty set: Set<Int>()
  • Null: null

operators
The following operators are supported:

  • Addition (numeric types) and string concatenation: +
  • Subtraction (numeric types): -
  • Multiplication (numeric types): *
  • Division (numeric types): /
  • Modulus (integer type): %
  • Casting (casts a variable as one of another type): as (example: 8 as Float)

binary operators

  • Equality: =
  • Inequality: !=
  • Bigger than: >
  • Bigger than or equal to: >=
  • Smaller than: <
  • Smaller than or equal to: <=
  • Instance of: is a (checks if a certain expression is of a certain type)
  • Contained in collection: in (checks if a certain expression is contained in a collection)
  • and: &&
  • or: ||
  • not: !

Example:

    if(!(b is a String) && (b in [8, 5] || b + 3 = 7)) {
       // ...
    }

variables
Variables can be accessed by use of their identifiers and their properties using the . notation. Example: person.lastName

list comprehensions
List comprehensions are a combination of mapping, filtering and sorting. Example:

    [e.title
     for(e : BlogEntry in b.entries 
         where e.created > date 
         order by e.created desc)]

This expression returns all titles (e.title) from b.entries where the time created (e.created) is greater than a certain date, ordered by e.created in descending order. Both the where and order by clauses are optional. An ordering is either ascending (asc) or descending (desc).

Contributions by ZefHemel