Skip to content

Latest commit

 

History

History
117 lines (86 loc) · 1.74 KB

File metadata and controls

117 lines (86 loc) · 1.74 KB

Basic syntax

Variables

  • Usual variables

    someVariable (str) = "Hello"
  • Read-only variables

    someValue (int const) = 10

Loops

  • For

    for i in iterator:
        doSomething
  • While

    while condition:
        doSomething

If instruction

if condition:
    doSomething
else condition2:
    doSomething2
else:
    doSomething3

Functions

  • Function declaration

    functionName (FunctionReturnType)
    argName1 (Arg1Type),
    argName2 (Arg2Type),
    argName3 (Arg3Type):
        return something
  • Function call

    # call a function providing with arg1 and the second argument is the result of anotherFunctionName function
    functionName arg1, (antherFunctionName argForAnotherFunction)

Comments

# As in python

Classes and objects

  • Definition

    class Person:
    # constants
        name (String const)
        age (int const)
        passport (Passport const)
    
    # variables
        mood (private String) = "OK"
    
    # constructors
        new (Person) # (Person) can be omitted
        name (String),
        age (int):
            this.name = name
            this.age = age
            this.passport = new name age
    
    # methods
        changeMood (void)
        newMood (String):
            this.mood = newMood
  • Create instance

    somePerson (Person const) = new "Rob", 12

Other examples

# variable assignment
helloVariable (String const) = helloFunction "MyName"

# helloWorld function
helloWorld (String)
name (String),
age (int):
    print ["Hello", name, ", ", age]

# call ctor
person (Person const) = Male.new "Rob"