On Tue, May 14, 2002 at 11:45:17PM +0900,
 Dossy wrote:

> That's pretty close to what I did.  I didn't know about the
> self.replace trick, and I don't see how your Param#to_a knows
> to return @val, unless that's how String#to_a is implemented
> (how was I supposed to know it returned @val without looking
> at the core?).

Oh, self.replace is not so good, maybe super() is better.

foo = "foo"
foo.replace("bar")
p foo   # => "bar"


to_a() is defined with each().

Ruby Language Reference Manual:
> Enumerable
>   Enumerable is the Mix-in module for the enumeration. The including class
>   must provide the method each. All methods provided by Enumerable are
>   defined using each.

module Enumerable
  def to_a
    ary = Array.new
    self.each{|i| ary.push(i) }
    ary
  end
end


-- 
Wakou Aoyama  <wakou / fsinet.or.jp>