Newbie help : Ruby Processin

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 =

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



Not sure I understand teh question, but in doing the setup method of
an Example81 object which inherits from Processing::App, you turn the
instance variable @my_car into a Car object by making a new one, with
the parameter of the new Car as the instance of the Example81 class
that you are working with.

Hello Philliam, Thank you for you response. I think that your response
has given me valuable insight into the code I attached earlier in that I
now understand that the keywork ‘self’ refers to the object that we are
currently in. But what is actually passed, a copy, or a reference to an
instance of Example81?

When we look at @app in the Car class what are .width and .height etc…
Sureley they would be methods of Example81 that have been inherited from
the App superclass. Is this a fair assumption to make?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs