2 in [1,2,3] -> true

hi,

i know

[1,2,3].member? 2 → true
is short but
2 in [1,2,3] → true
would be very, very cool. i miss that most in ruby.
this syntax comes from python, as far as i am concerned.

maybe some of you will say it isn t a good OO manner.
maybe some of you will say that it wouldn t fit ruby’s expression syntax
or concept

but i would like it so much that i had to get this lost.

  • Meinrad

batsman@kodos:/tmp$ expand -t2 b.rb
class Object
def in(o)
o.member? self
end
end

p 2.in [1,2,3]
batsman@kodos:/tmp$ ruby b.rb
true

The price you pay for staying with Ruby isn’t even one keystroke :slight_smile:

···

On Mon, Apr 07, 2003 at 02:46:03AM +0900, Meinrad Recheis wrote:

hi,

i know

[1,2,3].member? 2 → true
is short but
2 in [1,2,3] → true
would be very, very cool. i miss that most in ruby.
this syntax comes from python, as far as i am concerned.

maybe some of you will say it isn t a good OO manner.
maybe some of you will say that it wouldn t fit ruby’s expression syntax
or concept

but i would like it so much that i had to get this lost.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Never trust an operating system you don’t have sources for. :wink:
– Unknown source

Mauricio Fernández wrote:

batsman@kodos:/tmp$ expand -t2 b.rb
class Object
def in(o)
o.member? self
end
end

p 2.in [1,2,3]
batsman@kodos:/tmp$ ruby b.rb
true

creative solution.

The price you pay for staying with Ruby isn’t even one keystroke :slight_smile:

you never have to pay for using ruby :slight_smile:


cheers Meinrad

Sure, the cost of the electrons hitting your screen to draw the dot
instead of the space :wink:

···

On Mon, Apr 07, 2003 at 04:26:15AM +0900, Meinrad Recheis wrote:

p 2.in [1,2,3]
batsman@kodos:/tmp$ ruby b.rb
true

creative solution.

The price you pay for staying with Ruby isn’t even one keystroke :slight_smile:

you never have to pay for using ruby :slight_smile:


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Are we going to make an emacs out of apt?
APT - Debian in a program. It even does your laundry
– Seen on #Debian