Is it good that "everything is an object"?

I am learning Ruby on Rails for a class project. I keep hearing "everything in Ruby is an object." I'm not sure I understand why this is good, or maybe it's good?

+3
source share
4 answers

A counterexample will be that Integerthere is an object in Java , but intnot, which means that different operations are applied to them (admittedly, in recent Java there is an automatic conversion to / from the version of the object, but this may introduce unexpected performance problems) . Objects are a bit slower due to indirection, but more flexible; everything that is an object means that everything behaves sequentially. Again Java will be an example: an array is not an object, but ArrayIteratoris what is locked after the fact (with several third-party implementations, even) and, therefore, is not entirely consistent with how collection class iterators work.

+5
source

This makes Ruby very flexible. Numbers and other primitive types are subject to change or extension.

:

5.times { print "print this 5 times" }

+2

, , , Java. , , .

Ruby , , , . , Ruby . . Ruby , , , , - .

, , - , Ruby , , , . , Ruby . Ruby on Rails Ruby.

+1
source

All Articles