f4c25646c2452052e1b7c4db1279602433cc1766
Misc/Moelang.md
| ... | ... | @@ -20,4 +20,30 @@ |
| 20 | 20 | - Optional (can be `null`) |
| 21 | 21 | - `Type1(<paramX:TypeX>*)` |
| 22 | 22 | - Callable with params |
| 23 | - - Example Int(x: Int, y: Int) - a function with parameters x: Int, and y: Int, which returns Int |
|
| ... | ... | \ No newline at end of file |
| 0 | + - Example Int(x: Int, y: Int) - a function with parameters x: Int, and y: Int, which returns Int |
|
| 1 | + |
|
| 2 | +## Example type usage (`Complex` module) |
|
| 3 | +``` |
|
| 4 | +module Complex |
|
| 5 | + struct Complex |
|
| 6 | + re: Float |
|
| 7 | + im: Float |
|
| 8 | + end |
|
| 9 | + |
|
| 10 | + func conjugate -> Complex(c: Complex) |
|
| 11 | + return Complex { |
|
| 12 | + re=c.re, |
|
| 13 | + im=-c.im, |
|
| 14 | + } |
|
| 15 | + end |
|
| 16 | + |
|
| 17 | + cast -> Complex(f: Float) |
|
| 18 | + return Complex { |
|
| 19 | + re=f, |
|
| 20 | + im=0.0, |
|
| 21 | + } |
|
| 22 | + end |
|
| 23 | + |
|
| 24 | + operator["+"] -> Complex() |
|
| 25 | +end |
|
| 26 | +``` |
|
| ... | ... | \ No newline at end of file |