I would absolutely love if Array recursively performed #=== on its
arguments.  AFAICT Array#=== is practically identical to Array#==

On Fri, Dec 18, 2009 at 4:16 PM, Caleb Clausen <vikkous / gmail.com> wrote:

> > Dmitry Vazhov wrote:
> >> Hello,
> >>
> >> We already have :=== operator defined in Module, Range, Regexp and Proc
> >> which is great for case/when statement.  For all other objects :=== mean
> >> :==.
> >>
> >> My suggestion is to extend Array with === method:
>
> I long ago did something similar, but much more extensive; I created a
> large pattern-matching language/library for ruby data structures
> called Reg. Instead of changing the existing Array#===, I created a
> new class, Reg::Array, which has the functionality you want. A
> Reg::Array can be constructed by enclosing the patterns of interest
> between +[ and ].
>
> You should have a look at Reg; you can install the gem:
>  gem install reg
> or take a look at the github project, which contains newer (and buggier)
> code:
>  http://github.com/coatl/reg
>
>
> On 12/17/09, Dmitry Vazhov <dmitryelastic / gmail.com> wrote:
> > "Set" class has meaning close to "Range" class. If we will define
> > Set#=== as
> >
> > class Set
> >   def ===( arg )
> >     self.any?{|template| template === arg  }
> >   end
> > end
>
> Personally, I would rather see Set#=== be an alias for include?. The
> alternation semantics that you want here are provided in Reg by
> Reg::Or, which is usually created by gluing together individual
> matchers that you want with the | operator. So it'd look like:
>  Sexp = Array|Numeric
> instead of:
>  Sexp = Set[Array, Numeric]
>
>


-- 
Tony Arcieri
Medioh! A Kudelski Brand