In message "[ruby-talk:00434] Re: New feature for Ruby?"
on 99/07/08, Clemens Hintze <c.hintze / gmx.net> writes:
>Woah! T h a t i s w o n d e r f u l !!! :-)))))))))))))))))
>
>I didn't know, that this is possible... I did know concerning
>Singleton methods... but this... <cannot believe what he sees...>
How unhappy you were!! But I'm sorry I also don't know where it is
documented... Some bundled libraries use this feature (e.g.,
complex.rb, expect.rb).
>But does that mean, I cannot redefine an already defined class?
I think that completely redefining is impossible.
>PS: Would it makes sense to introduce that feature in the
>Ruby-Manual? Perhaps it is, but I cannot remember I did see that!
>Furthermore please explain `alias' more a little bit. I could not see
>from the manual, whether the syntax is `alias old new' or `alias new
>old'.
Like a shell, `alias new old'. `alias' is also useful to modify a
method:
class Array
alias ref []
private :ref
def [](*ind)
ind.collect{|i| ref(i)}
end
end
eto = [:ne,:ushi,:tora,:u,:tatsu,:mi,:uma,:hitsuzi,:saru,:tori,:inu,:i]
p eto[2,5,6,10].filter{|i| i.id2name} #=> ["tora", "mi", "uma", "inu"]
HTH
# I'll reply again to discuss about Range.
-- gotoken