mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-10-16 05:50:19 +00:00
fixed __getter and __setter tables
This commit is contained in:
20
examples/getters_setters.cosmo
Normal file
20
examples/getters_setters.cosmo
Normal file
@@ -0,0 +1,20 @@
|
||||
var object = {
|
||||
__setter = [
|
||||
"field1" = function(self, val)
|
||||
print("setter for field1 called!")
|
||||
self.x = val
|
||||
end
|
||||
],
|
||||
|
||||
__getter = [
|
||||
"field1" = function(self)
|
||||
print("getter for field1 called!")
|
||||
|
||||
return self.x + 1
|
||||
end
|
||||
]
|
||||
}
|
||||
|
||||
object.field1 = 1337
|
||||
|
||||
print("got field: " .. object.field1)
|
Reference in New Issue
Block a user