DEV Community

Discussion on: Everything is an Object!

Collapse
 
craigbrad profile image
Craig Bradley

It's not necessarily a good thing, but in my opinion it's what allows me to write more expressive code quickly and easily. For example, simple checks:

In c++ to check a number is equal to zero we can do the following:

int num = 0;

if (num == 0) {
  return "match";
}

In ruby we can do it this way:

num = 0

if num.zero?
  "match"
end

I prefer the ruby way of doing this as it is much simpler to read. It's closer to English. Ruby provides hundreds of useful methods, just take a look at the Numeric class in the ruby docs.

That's not to say one is better than the other. If you're looking for performance, then you are probably not going to be using ruby anyway.