Gosu statement terminators

The recommended way to terminate a Gosu statement and to separate statements is:

  • A new-line character, also known as the invisible \n character

Although not recommended, you may also use the following to terminate a Gosu statement:

  • A semicolon character (;)
  • White space, such as space characters or tab characters

In general, use new-line characters to separate lines so that Gosu code looks cleaner.

For typical code, omit semicolons because they are unnecessary in almost all cases. Standard Gosu style uses semicolons between multiple Gosu statements when they are all on one line. For example, a short Gosu block definition uses this style. However, even in those cases, semicolons are optional in Gosu.

Valid and recommended

// Separated with newline characters
print(x)
print(y)

// If defining blocks, use semicolons to separate statements
var adder = \ x : Integer, y : Integer -> { print("I added!"); return x + y; }

Valid but not recommended

// NO - Do not use semicolon
print(y); 

// NO - Do not rely on whitespace for line breaks. It is hard to read and errors are common.
print(x) print(y) 

// NO - Do not rely on whitespace for line breaks. It is hard to read and errors are common.
var pnum = Policy.PolicyNumber cnum = Claim.ClaimNumber
Important: In almost all cases, omit semicolon characters in Gosu. However, standard Gosu style uses semicolons between multiple Gosu statements on one line, such as in short Gosu block definitions.

Invalid statements

var pnum = Policy.PolicyNumbercnum = Claim.ClaimNumber

See also