Definition
This lesson will explain how to define your method in Ruby.
Defining a Method
So far you have seen methods that “belong” to objects, or, in other words,
are defined on objects, and can be called on objects. E.g. you have seen the
method downcase
which is defined on every string.
However, Ruby also knows methods that are not defined on any of these objects. They’re sort of “stand-alone” methods.
For example, you can try this in irb
:
$ irb
> is_a?(Object)
true
Press + to interact
puts is_a?(Object)
We’ll use this type of methods in this chapter because we want to focus on the characteristics of ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy