Operator overloading test
This commit is contained in:
14
examples/operator_overloading.kl
Normal file
14
examples/operator_overloading.kl
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
Vec3 :: struct;; x: F32; y: F32; z: F32
|
||||
"+" :: (a: Vec3, b: Vec3): Vec3 ;; return Vec3{a.x+b.x, a.y+b.y, a.z+b.z}
|
||||
|
||||
|
||||
main :: (): int
|
||||
a := Vec3{1,1,1}
|
||||
b := Vec3{2,3,4}
|
||||
c := a + b
|
||||
Assert(c.x == 3)
|
||||
Assert(c.y == 4)
|
||||
Assert(c.z == 5)
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user