Forum: Ruby Everything in ruby is an object?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5860439cab5dd9f238c8555a7f9bcbdd?d=identicon&s=25 Mark Gargan (markgargan)
on 2007-06-22 09:57
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.
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jano Svitok (Guest)
on 2007-06-22 10:57
(Received via mailing list)
On 6/22/07, Mark Gargan <mark.gargan@gmail.com> 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.
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2007-06-22 11:05
(Received via mailing list)
On 22.06.2007 09:57, Mark Gargan 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
Ba608f20b6707017d9812b9b3f1406e3?d=identicon&s=25 gpy good (gpygood)
on 2007-06-22 11:16
Jano Svitok wrote:
> On 6/22/07, Mark Gargan <mark.gargan@gmail.com> 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
5860439cab5dd9f238c8555a7f9bcbdd?d=identicon&s=25 Mark Gargan (markgargan)
on 2007-06-22 11:42
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.
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Tim Hunter (Guest)
on 2007-06-22 13:05
(Received via mailing list)
Mark Gargan 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.
This topic is locked and can not be replied to.