operator overload for [], []=, =

This commit is contained in:
Nathan Braswell
2016-03-02 20:23:25 -05:00
parent 84cbcc3820
commit 22feae1a58
4 changed files with 54 additions and 8 deletions

View File

@@ -1 +1,3 @@
bracket assign: index: 4, rhs: 9
just bracket: index: 5
just =: index: 6

View File

@@ -7,10 +7,20 @@ obj BracketAssign {
print(", rhs: ")
println(rhs)
}
fun operator[](index:int) {
print("just bracket: index: ")
println(index)
}
fun operator=(index:int) {
print("just =: index: ")
println(index)
}
}
fun main():int {
var test:BracketAssign
test[4] = 9
test[5]
test = 6
return 0
}