[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: define_method fun

Gabe Boyer

2/18/2006 5:53:00 AM

Take a look at the Comparable[1] module. It's a much cleaner, simpler
way to accomplish what you're doing.

[1] http://www.ruby-doc.org/core/classes/Compa...

Gabe

On 2/17/06, Patrick Ritchie <pritchie@videotron.ca> wrote:
> Hi All,
>
> I just setup the following in one of my classes, I'll let the code speak
> for itself:
>
> ["<", "<=", ">", ">=", "==", "<=>"].each do |op|
> define_method(op) { |comparison| eval "#{self.order} #{op}
> #{comparison.order}" }
> end
>
> Ruby continues to impress me with it's ability to do so much in so few
> amazing readable lines of code.
>
> Are their any good reasons not to declare my op methods this way? Is
> their an even more efficient way to achieve the same effect?
>
> Cheers!
> Patrick
>
>


3 Answers

Patrick Ritchie

2/18/2006 2:52:00 PM

0

Definitely cleaner in my case, thanks for the tip!

Cheers!
Patrick

>Take a look at the Comparable[1] module. It's a much cleaner, simpler
>way to accomplish what you're doing.
>
>[1] http://www.ruby-doc.org/core/classes/Compa...
>
>Gabe
>
>On 2/17/06, Patrick Ritchie <pritchie@videotron.ca> wrote:
>
>
>>Hi All,
>>
>>I just setup the following in one of my classes, I'll let the code speak
>>for itself:
>>
>>["<", "<=", ">", ">=", "==", "<=>"].each do |op|
>> define_method(op) { |comparison| eval "#{self.order} #{op}
>>#{comparison.order}" }
>>end
>>
>>Ruby continues to impress me with it's ability to do so much in so few
>>amazing readable lines of code.
>>
>>Are their any good reasons not to declare my op methods this way? Is
>>their an even more efficient way to achieve the same effect?
>>
>>Cheers!
>>Patrick
>>
>>
>>
>>
>
>
>
>

Dr. Strangemonde

4/29/2010 3:54:00 PM

0

On Apr 29, 8:48 am, LookingGlass <goldencocke...@gmail.com> wrote:
> He wasn't a *fan* of The Beatles...but grudgingly gives them their
> credit by the end of the series.

Kinda reminds me of when I spoke at length with Stan Freberg -- he
didn't so much sound as though he was a Beatles fan as he was proud
that he himself had been famous enough to get the Fabs to pose for a
photo with his kids!

- Dr S

On a tangent, I just recently found out that an old U-matic tape that
I thought was blanked actually still has about 2/3rds of a 30 minute
Jerry Pam interview still on it. It's from the late '70s, though, and
doesn't seem to have any Beatles content...

6SickStrings@gmail.com

4/29/2010 6:15:00 PM

0

On Apr 29, 9:48 am, LookingGlass <goldencocke...@gmail.com> wrote:
> On Apr 28, 7:08 pm, "Bob, K1BC" <fake.addr...@k1bc.com> wrote:
>
>
>
> > Thanks for this heads-up.  I got my copy in the mail yesterday and
> > have listened to the first of the four shows.  (Nothing Beatley in it..)
>
> > I listened to Shep for some years in NYC.  I met him a couple times
> > during that period.  Well, said "Hi" to him, really, at a couple events
> > he was hosting.  And I talked to him on the radio (ham radio, not his
> > show) once as he was passing through the Boston area on the way to
> > Maine.  He was K2ORS.  A very nice guy in person.
>
> > Bob, K1BC
>
> He wasn't a *fan* of The Beatles...but grudgingly gives them their
> credit by the end of the series. The obvious focus of the series is
> the JS perspective...otherwise, what's the point! And his perspective
> was very likeable. I like him.
>
> www.Shemakhan.com
>
> --
>
> All follow-ups are directed to the newsgroup rec.music.beatles.moderated.    
> If your follow-up more properly belongs in the unmoderated newsgroup, please
> change your headers appropriately.   -- the moderators
> --

I was wondering if he might be a bit on the curmudgeonly side vis a
vis the Beatles, he was more of a 'beatnick' type back in those days,
I seem to recall him being associated with Lenny Bruce and some other
Greenwich Villiage troublemakers.

--

All follow-ups are directed to the newsgroup rec.music.beatles.moderated.
If your follow-up more properly belongs in the unmoderated newsgroup, please
change your headers appropriately. -- the moderators
--