Everything in ruby is an object?


#1

Hey folks,

  I'm reading the tutorial on Ruby located at

http://www.rubycentral.com/book/

In it the guys state that everything in Ruby is an object.
I was just wondering if that applies to Boolean expressions
i.e. the likes of && and ||. Is there a wrapper object for these
types? I’ve written a small expression filter that retrieves a boolean
expression from the db and I was just wondering if there was a quicker
way of processing it other than a case statement.

Thanks,
Mark.


#2

On 6/22/07, Mark G. removed_email_address@domain.invalid wrote:

types? I’ve written a small expression filter that retrieves a boolean
expression from the db and I was just wondering if there was a quicker
way of processing it other than a case statement.

Thanks,
Mark.

No. Expressions are not objects. Objects are true and false, and && ||
are methods.
Expressions are series of calls.


#3

On 22.06.2007 09:57, Mark G. wrote:

  I'm reading the tutorial on Ruby located at

http://www.rubycentral.com/book/

In it the guys state that everything in Ruby is an object.
I was just wondering if that applies to Boolean expressions
i.e. the likes of && and ||. Is there a wrapper object for these
types?

No expression in Ruby is an object. But results of evaluating them are
objects. There is no real boolean type in Ruby as the rule is “nil and
false are false, everything else is true”.

I’ve written a small expression filter that retrieves a boolean
expression from the db and I was just wondering if there was a quicker
way of processing it other than a case statement.

Not sure what you are at here. Can you show a short example of what you
are doing? (Not the DB retrieval but the postprocessing)

Kind regards

robert


#4

Jano S. wrote:

On 6/22/07, Mark G. removed_email_address@domain.invalid wrote:

types? I’ve written a small expression filter that retrieves a boolean
expression from the db and I was just wondering if there was a quicker
way of processing it other than a case statement.

Thanks,
Mark.

No. Expressions are not objects. Objects are true and false, and && ||
are methods.
Expressions are series of calls.

I think && is NOT method:
1.try:
class A
def &&
end
end

#parse error, unexpected tANDOP def && ^

2.& is a method,but && is not.because ruby eval method’s arg


#5

Thanks a million folks. That answers that I guess.
i’m not going to go about developing a class that will effectively just
mimic the case statement.

Would you guys know of any all in introduction to ruby on rails??

I’ve been working with JRuby for the past few weeks and would love to
see how
applicable it is to enterprise apps.

Thanks,
Mark.


#6

Mark G. wrote:

Thanks a million folks. That answers that I guess.
i’m not going to go about developing a class that will effectively just
mimic the case statement.

Would you guys know of any all in introduction to ruby on rails??

I’ve been working with JRuby for the past few weeks and would love to
see how
applicable it is to enterprise apps.

Rails? What’s Rails?

Seriously, there’s a whole web site devoted to RoR: www.rubyonrails.org.
Lots of suggestions about tutorials and books there. Also there’s a
whole newsgroup devoted to Rails: http://www.ruby-forum.com/forum/3.
It’s full of people who like to talk about Rails stuff.