HackerRank Ruby Tutorial - Everything is an object problem solution

In this HackerRank Ruby Tutorial - Everything is an object problem solution in ruby everything is treated as an object. every piece of code has it's own properties and actions.

 Everything is an object in Ruby. For instance, if you type

print self

in the code editor, Ruby treats self as the object to which it is currently referred to.

Give it a try!

hackerrank ruby tutorial - everything is an object problem solution


Problem solution.

# Enter your code here. Read input from STDIN. Print output to STDOUT
print self


In ruby, everything that appears is called an object. that's why ruby is a pure object-oriented programming language. every single value like string, number, class is an object in ruby.

In ruby, an object is called a blueprint for instance, so basically an object is created from a class and we declare objects of a class using the new keyword.

object_name = class_name.new

Post a Comment

0 Comments