[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:04093] Possible new bit of syntax sugar?

From: hal9000@...
Date: 2000-07-17 18:29:07 UTC
List: ruby-talk #4093
In conjunction with a "set" class I've been playing with,
I added a method called "in" to Object, so that I could
use the "natural" notation instead of the "backwards" one.

E.g.: 'if x.in s' instead of 'if s.include? x'

Of course, it would really look nicer without the dot:

     if x in s

I'm thinking that this could be defined to call the include?
method for the receiver (and thus would work with arrays or
anything else that had an include? method -- e.g.,
'if item in mybinarytree' ...)

Also:

I've noticed that there is a member? method for ranges and an
include? method for arrays. I realize that conceptually these
are very different things, but still... I wonder if it would
be helpful to alias include? to member? for ranges (especially
in light of the above idea)?

Just a thought...
Hal

--
Hal Fulton


Sent via Deja.com http://www.deja.com/
Before you buy.

In This Thread

Prev Next