Your first Rush lines

Print a line, bind a name to a value, and learn the one rule every line must follow.

0XP
0Stars
1Level

Video

Read

A Rush program is a list of lines, and every line has to do something. The smallest useful line prints text. To print, call write:

write['hello world']

Look at the square brackets. In Rush, [ and ] are the only grouping brackets: the arguments of a call go inside them, with commas between arguments, as in f[a, b]. Parentheses are refused outside text. The text goes to standard output.

To remember a value, bind a name to it with =. Rush has no variables: a bind joins a label, a name without quotes, to a value. Then write[x] prints the value bound to x:

x = 5
write[x]

One rule governs every line: a line must bind, call or route. A line that only names a value, like 5 on its own, does nothing, so Rush refuses it with the error RX0065 before anything runs.

Exercises

Which of these lines is refused because it does nothing?

Choose one

Which brackets hold the arguments of a call in Rush?

Choose one

Write one line that prints hello world.

The exercise asks for this output:

hello world

The Rush cloud runner is not connected yet, so code cannot be run from this page. Nothing was executed and no output is shown.

Bind the name x to 5, then print x.

The exercise asks for this output:

5

The Rush cloud runner is not connected yet, so code cannot be run from this page. Nothing was executed and no output is shown.

All lessons

Stars, XP and confetti are only symbols: they do not unlock or cost anything. They are here to make you want to keep going.