J
Jerome david Sillinger
Hello, Looking at the code in the attached file can someone please
explain to me in simple terms why in the method
------------------------------------------------------
class Example81 < Processing::App
def setup
size screen.width/2, screen.height/2
#Initialize car object
@my_car = Car.new(self)
end
------------------------------------------------------
why is 'self' is passed as a parameter also why does the initializer for
the Car class look like this?
------------------------------------------------------
class Car #define a class below the rest of the program
def initialize(app)
------------------------------------------------------
I understand that 'self' refers to the current object and objects use
them to call methods defined within themselves.
Please see the attachement for a better picture of the context of the
code
Thanks
JD
Attachments:
http://www.ruby-forum.com/attachment/4441/example81.rb
explain to me in simple terms why in the method
------------------------------------------------------
class Example81 < Processing::App
def setup
size screen.width/2, screen.height/2
#Initialize car object
@my_car = Car.new(self)
end
------------------------------------------------------
why is 'self' is passed as a parameter also why does the initializer for
the Car class look like this?
------------------------------------------------------
class Car #define a class below the rest of the program
def initialize(app)
------------------------------------------------------
I understand that 'self' refers to the current object and objects use
them to call methods defined within themselves.
Please see the attachement for a better picture of the context of the
code
Thanks
JD
Attachments:
http://www.ruby-forum.com/attachment/4441/example81.rb