[#407] New feature for Ruby? — Clemens.Hintze@...

Hi all,

27 messages 1999/07/01
[#413] Re: New feature for Ruby? — matz@... (Yukihiro Matsumoto) 1999/07/01

Hi Clemens,

[#416] Re: New feature for Ruby? — Clemens Hintze <c.hintze@...> 1999/07/01

On Thu, 01 Jul 1999, Yukihiro Matsumoto wrote:

[#418] Re: New feature for Ruby? — gotoken@... (GOTO Kentaro) 1999/07/01

Hi

[#426] Re: New feature for Ruby? — gotoken@... (GOTO Kentaro) 1999/07/02

Hi,

[#440] Now another totally different ;-) — Clemens Hintze <c.hintze@...>

Hi,

21 messages 1999/07/09
[#441] Re: Now another totally different ;-) — matz@... (Yukihiro Matsumoto) 1999/07/09

Hi,

[#442] Re: Now another totally different ;-) — Clemens Hintze <c.hintze@...> 1999/07/09

On Fri, 09 Jul 1999, you wrote:

[#443] — Michael Hohn <hohn@...>

Hello,

26 messages 1999/07/09
[#444] interactive ruby, debugger — gotoken@... (GOTO Kentaro) 1999/07/09

Hi Michael,

[ruby-talk:00436] redefinition and alias (Re: New feature for Ruby?)

From: gotoken@... (GOTO Kentaro)
Date: 1999-07-08 20:15:25 UTC
List: ruby-talk #436
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

In This Thread