If statements

From CodeStuff
Revision as of 20:53, 19 June 2014 by Lerc (Talk | contribs) (Created page with "You can use if statements to optionally run a piece of code. The if statement takes the form if (condition) { actions; } <edcode> if (true) { print("this text will al...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can use if statements to optionally run a piece of code.

The if statement takes the form

if (condition) {
 actions;
}


You can optionally provide code to be run when the condition is not true with else.

if (condition) {
  things to do when the condition is true
} else {
  otherwise do the things here
}


In the example Below, the circle is filled when the mouse pointer is inside it.