[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: neat idea from arc

Yukihiro Matsumoto

1/29/2008 10:25:00 PM

Hi,

In message "Re: neat idea from arc"
on Wed, 30 Jan 2008 07:07:31 +0900, "Martin DeMello" <martindemello@gmail.com> writes:

|So we can write, for instance
|
|ints = input.select Integer

We can do it by using #grep, e.g.

ints = input.select Integer

matz.

2 Answers

Martin DeMello

1/30/2008 6:09:00 AM

0

On Jan 29, 2008 10:24 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: neat idea from arc"
> on Wed, 30 Jan 2008 07:07:31 +0900, "Martin DeMello" <martindemello@gmail.com> writes:
>
> |So we can write, for instance
> |
> |ints = input.select Integer
>
> We can do it by using #grep, e.g.
>
> ints = input.select Integer

I was thinking of this as a replacement for (and generalisation of)
grep, since it would extend to other methods like #reject and
#partition too

martin

Pit Capitain

1/31/2008 12:50:00 PM

0

2008/1/30, Martin DeMello <martindemello@gmail.com>:
> I was thinking of this as a replacement for (and generalisation of)
> grep, since it would extend to other methods like #reject and
> #partition too

Martin, you can define

class Object
def to_proc
lambda {|e| self === e }
end
end

and then

[3,1,4,1,5].all?(&(1..5))) # => true

Regards,
Pit