Cosmo/examples/getters_setters.cosmo

20 lines
364 B
Plaintext

let object = {
__setter = [
"field1" = func(self, val)
print("setter for field1 called!")
self.x = val
end
],
__getter = [
"field1" = func(self)
print("getter for field1 called!")
return self.x + 1
end
]
}
object.field1 = 1337
print("got field: " .. object.field1)