Everything is an Object

don't objectify please...

·

2 min read

Good Evening, lads!

If you watched the video shared in the previous article and understood as much as 20% of it, congratulations!

You know 19% more than me. I'm guessing.

Somewhere in the middle of the video, Dave Thomas explains why he loves Ruby and explains how Ruby operates under the Object-Oriented paradigm. As the title goes,

Everything in Ruby is an Object!

As far as I know, that is not the case with other object-oriented languages like C++.

In C++, Java, etc... Object is an instance of a class.

You define a class using it's keyword generally "Class" and the instances of the said class will act as objects.

As for syntax, class in Ruby is defined using the keyword "Class".

Now to the idea: Everything in Ruby is an Object!

Extending on the video, the Ruby interpreter consumes everything written in Ruby like variables, classes, constants, functions, data types, etc... as an instance of its own SuperClass.

Defining a string in ruby,

string = "Hello World!"

Simply put, inherits an object from the String SuperClass to create and assign a string. Same goes for EVERYTHING IN RUBY, an OBJECT.

Now the StringClass is an instance of its own SuperClass and on and on.

If you are already familiar with Object Oriented programming languages, you must have seen the keyword self.

A literal meaning of self can be called "the current object".

That is, the current instance of a class. Please refer to other sources if you still can't understand the idea behind objects & self.

Once understood, Rails will be much more fun and simple to learn. Trust me on it!

Thank you.

Until then...

Love,

M.

liked_the_post == true ? comment and share : comment and share