[#6363] Re: rescue clause affecting IO loop behavior — ts <decoux@...>

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

17 messages 2000/11/14
[#6367] Re: rescue clause affecting IO loop behavior — David Alan Black <dblack@...> 2000/11/14

Hello again --

[#6582] best way to interleaf arrays? — David Alan Black <dblack@...>

Hello --

15 messages 2000/11/26

[#6646] RE: Array Intersect (&) question — Aleksi Niemel<aleksi.niemela@...>

Ross asked something about widely known and largely ignored language (on

23 messages 2000/11/29
[#6652] RE: Array Intersect (&) question — rpmohn@... (Ross Mohn) 2000/11/29

aleksi.niemela@cinnober.com (Aleksi Niemel) wrote in

[#6723] Re: Array Intersect (&) question — Mathieu Bouchard <matju@...> 2000/12/01

> >Use a hash. Here's code to do both and more. It assumes that

[#6656] printing/accessing arrays and hashes — raja@... (Raja S.)

I'm coming to Ruby with a Python & Common Lisp background.

24 messages 2000/11/30

[ruby-talk:6267] Re: aliasing class methods

From: Minero Aoki <aamine@...>
Date: 2000-11-11 05:59:57 UTC
List: ruby-talk #6267
Hi David,

  In mail "[ruby-talk:6264] aliasing class methods"
    David Alan Black <dblack@candle.superlink.net> wrote:

> Hello --
> 
> Is there more compact way to alias class methods than this
> (i.e., without the necessity of "class << self ... end")?

This is a little "illegal" way, but usable:

class T
  def T.a
    puts 'a called'
  end
  instance_eval "alias b a"
end
T.a   #-> a called
T.b   #-> a called


And we can make this code more compact by the following way:

class Module
  def alias_class_method( new, old )
    instance_eval "alias #{new.id2name} #{old.id2name}"
    # or "instance_eval { alias_method new, old }"
  end
end

class T
  alias_class_method :c, :a
end
T.c   #-> a called


> In a related vein: what functionality does alias_method add to alias?
> I've been playing with both, and in cases where either works, both
> seem to work (even if with slightly different syntax).

In a word, "alias" is required to aliasing global variables.
"alias_method" is required to using in method.


Minero Aoki


In This Thread

Prev Next