/examples/equality.nct
equality.nct
use std/io.print
use std/vec.Vec
struct Point {
x: i32,
y: i32,
}
instance Point {
pub operator (&self == other: &Self): bool {
return self.x == other.x && self.y == other.y
}
}
func main(): i32! {
let first = Point { x: 3, y: 4 }
let same = Point { x: 3, y: 4 }
let other = Point { x: 5, y: 6 }
if first != same || first == other {
return 1
}
let points = Vec [move first, move other]
if !points.contains(&same) {
return 1
}
if points[0] != same {
return 1
}
var values = Vec [1, 2, 3]
values[1] = 4
if values[0] + values[1] + values[2] != 8 {
return 1
}
print("equality found the point\n")?
return 0
}