$ orcrist exec <filename.oc>
def foo(a,b):
a + b
A method is defined with the def
keyword, followed by an identifier and params. The colon indicates, that following lines are indented.
foo(a,b)
with params
foo
without params. Parentheses are optional here.
Assign a method to a variable and call it:
def add(a,b):
a + b
my_add = add
my_add(1,2) #=> 3
def foo(a,b):
a + b
add = foo
add(1,2)
When you do addition or subtraction, types are checked:
3 - 4 # => ok
3 + 5 # => ok
3 + true # => Error