The first thing you should know about Ruby is that there are no class methods. What we commonly refer to as a "class method" is simply a regular singleton method. Singleton methods can be found on any object; classes aren't required.
In Ruby, a method is a collection of expressions that returns a value. You can structure your code within a method into subroutines that can be conveniently called from other parts of the application.
In object-oriented programming, a class is used to describe one or more objects. It's used to create or instantiate certain objects within a program. While each object is made up of a single class, that same class can be utilized to make many objects.
Instance methods require a class instance and have access to it via self. A class instance is not required for class methods. They can't get to the instance (self), but they can get to the class using the cls command.
Share With Friend
Have a friend to whom you would want to share this course?
Download LearnVern App
Code Scan
or
Download the app
598K+
Downloads
4.57
Avg. Ratings
15K+
Reviews
Learn anywhere on the go
Get regular updates about your enrolled or new courses
Share content with your friends
Evaluate your progress through practice tests
No internet connection needed
Enroll for the webinar and join at the time of the webinar from anywhere
Enjoying this course!
All the Courses on Learnvern are Free! So Register/Sign in to
have Access all the Courses and Videos.