In the tutorial Rubymonk says :
“In Ruby, just like in real life, our world is filled with objects. Everything is an object – integers, characters, text, arrays – everything.”
But && and || are operators, operators are objects too ? how check ?
this is not going against the philosophy of ruby “All is a object” ?
It depends on how you define “everything”. I personally would never claim that each individual concept in ruby is an object. I suppose there isn’t really a good definition to describe how ruby works. I think you just have to accept the way ruby does it, which will become plain as you use it.
If you want to see if something is an object, try assigning it to a variable, or calling a method on it. You’ll get an error if you try to do that with an operator. A notable exception is methods, which aren’t objects but return objects.
Note that the concept of an object is somewhat abstract. Two variables can point to the same object. Every object is represented by an
object_id. You might think of an object_id like a location in memory. Or, you can think of an object as a house, and multiple address books can contain the house’s address.Continuing the house analogy, appending to a string via
<<is like bringing a new chair into the house. Everyone who follows their address book to that house (using the address) will see that the house (object) has the new chair.The ruby language designers did not see a reason to allow treating operators like
&&as objects. Can you see any reason to allow it?