Hi.  Could anyone help me understand the following?  I am reading a
piece of code that someone else wrote.


  class RegexAlternation < Array
    def sort
      self.clone.replace(super)
    end

    def uniq
      self.clone.replace(super)
    end

    def map
      self.clone.replace(super {|x| yield(x)})
    end

    def delete_if
      self.clone.replace(super {|x| yield(x)})
    end

    def select
      self.clone.replace(super {|x| yield(x)})
    end
  end

It looks like overriding the existing methods.  But the definitions are
very simple, so I am kinda lost here.

I appreciate if you provide some test codes to see what they do.

soichi

-- 
Posted via http://www.ruby-forum.com/.