Quick reference
If you already know RPL or are an experienced programmer, you can use this section as a quick reference.
Specifying values directly
|
Type |
Example |
|
String |
"Foo" or 'Foo' or "It's \"quoted\"" or r"C:\raw\string" NOTE: In the above example, using |
|
Number |
123.45 |
|
Boolean |
true, false |
|
Sequence |
["foo", "bar", 123.45], 1..100 |
|
Hash |
{"name":"green mouse", "price":150} |
Retrieving variables
|
Type |
Example |
|
Top-level variable |
user |
|
Retrieving data from a hash |
user.name, user["name"] |
|
Retrieving data from a sequence |
products[5] |
|
Special variables |
main |
String operations
|
Operation |
Example |
|---|---|
|
Interpolation or concatenation |
"Hello ${user}!" (or "Inter" + "act") |
|
Getting a character |
name[0] |
Sequence operations
Operation |
Example |
|
Concatenation |
users + ["guest"] |
|
Sequence slice |
products[10..19] or products[5..] |
Hash operations
Operation |
Example |
|
Concatenation |
passwords + {"joe":"secret42"} |
Numeric/Boolean expressions
Expression Type |
Example |
|---|---|
|
Arithmetical calculations |
(x * 1.5 + 10) / 2 - y % 100 |
|
Comparison |
x == y, x != y, x < y, x > y, x >= y, x <= y, x < y, ...etc. |
|
Logical operations |
!registered && (firstVisit || fromEurope) |
|
Built-ins |
name?upper_case |
|
Method call |
repeat("What", 3) |
Missing value handler operators
Action |
Example |
|
Default value |
name!"unknown" or (user.name)!"unknown" or name! or (user.name)! |
|
Missing value test |
name?? or (user.name)?? |