00:00
03:32
Understanding how the documentation is laid out can be helpful when learning ruby. This means we have to understand the difference between Class methods and instance methods.
Class Methods
Class methods are methods that need to be called in the context of a class for example
Integer.sqrt(9)
=> 3
We are calling the .sqrt method from the Integer class this is known as a class method.
Instance Methods
Instance methods are methods that need to be called on the instance for example 2 is an instance of the class Integer
2.odd?
=> false
2.even?
=> true
In this case .odd? and .even? are instance methods, they need to be called from the instance itself.