Learn Ruby
Instance Method
20.8
Lesson

Multiple arguments

Let’s create a new class called Appbuilder. This class builds apps.

class Appbuilder
end

instagram = Appbuilder.new
fortnight = Appbuilder.new

Here instagram and fortnight are instances of class Appbuilder. For each instance we want a method called info which will produce information about the app. The information needs to be in the following format.

From Instagram: Instagram is a photo sharing app.
From fortnight: Fortnight is a gaming app.

Let’s add method info to the class.

In this case method info takes two arguments: name and type.

In Ruby a method can take any number of arguments.