Hi. I’ve been wondering what self. did for a while now. There’s lots of them in the example projects but i just don’t know what they do. I’ve been looking in the tutorials but I haven’t found it. Can someone explain to me what self. does?
And example is:
Test = class()
Test:init(x,y)
self.x = x
self.y = y
--x and y are variables that are defined when :init is called in setup()
--self.x and self.y are the same as x and y, but can only be used with the Test class.
end
self is used in classes to define variables that only apply to that class.
@Kolosso - try these
https://coolcodea.wordpress.com/2013/03/22/7-classes-in-codea/
https://coolcodea.wordpress.com/2013/03/23/8-classes-in-codea-2/
Thanks. I did a little testing, and now I think I get it.