3 # The keyword `struct` is used to define structures
4 # that hold multiple members:
5 struct Point(x:Int, y:Int)
7 # Methods are any function defined inside of the
8 # indented area below a struct definition.
10 # There is no implicit `self` argument, only the
11 # arguments you explicitly define.
12 func abs(p:Point -> Point)
13 return Point(p.x.abs(), p.y.abs())
15 # Constants can be declared inside of a struct's namespace:
18 # Arbitrary functions can also be defined here:
19 func squared_int(x:Int -> Int)
24 # You can create a struct instance like this:
27 assert p == Point(x=???, y=???)
29 assert Point.ZERO == Point(x=???, y=???)
36 assert Point.squared_int(5) == ???