Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Aliasing classes

Reply
Thread Tools

Aliasing classes

 
 
Shak Shak
Guest
Posts: n/a
 
      06-30-2010
Hi all,

Is it possible to alias a class? That is for ClassA.run to call
ClassB.run instead? I have a third party library requiring a dependency
which I've already defined with my own name. I'm currently subclassing,
but I was wondering if there was a better way.

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

 
Reply With Quote
 
 
 
 
Jacob Mitchell
Guest
Posts: n/a
 
      06-30-2010
[Note: parts of this message were removed to make it a legal post.]

Yes, you simply set some variable equal to the name of a class and then in
that scope it's a class alias.

class A
attr_accessor
def initialize
@x = 2
end
end

a = A.new
puts a.x #=> 2

B = A
b = B.new
puts b.x #=> 2
puts b.class #=> A

On Wed, Jun 30, 2010 at 10:55 AM, Shak Shak <> wrote:

> Hi all,
>
> Is it possible to alias a class? That is for ClassA.run to call
> ClassB.run instead? I have a third party library requiring a dependency
> which I've already defined with my own name. I'm currently subclassing,
> but I was wondering if there was a better way.
>
> Shak
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aliasing palmis Java 0 02-02-2006 08:32 PM
More anti-aliasing puzzles Roedy Green Java 25 08-16-2005 07:41 PM
Aliasing a class name? Wesley T Perkins Java 8 07-01-2005 01:56 AM
Anti-aliasing GIF Images Kevin Bertman Java 4 11-29-2004 05:46 AM
LCD anti-aliasing in Java Tim Tyler Java 2 09-05-2003 09:01 AM



Advertisments