Alias for a class?

Hi all,

Last night I was playing with some third-party lib and found myself
having to type StupidlyLongLibName::LongModuleName::LongClassName
repeatedly and I wanted a mechanism where I could rename these classes
for my own use to cut down on the finger typing.

I thought I could just do:

class Shortname < OldLongClassName; end

Unfortunately this didn't work (yes there's no error thrown, but the
later code expected OldLongClassName and wouldn't work with Shortname

So my request is:
b: if not can it be added (perhaps with aka)?

Thanks
Kev

···

a: is it possible to alias a class (I know you can do it with methods)?

Kevin Jackson wrote:

a: is it possible to alias a class (I know you can do it with methods)?

SomeClass = SomeOtherClass

You can store that class in any variable or constant you like. So all of these work:

$cl = ::StupidlyLongLibName::LongModuleName::LongClassName
@cl = ::StupidlyLongLibName::LongModuleName::LongClassName
@@cl = ::StupidlyLongLibName::LongModuleName::LongClassName
cl = ::StupidlyLongLibName::LongModuleName::LongClassName
Cl = ::StupidlyLongLibName::LongModuleName::LongClassName

Note: depending on where in the code you are some of these do not really make sense.

Kind regards

    robert

···

Kevin Jackson <foamdino@gmail.com> wrote:

So my request is:
a: is it possible to alias a class (I know you can do it with
methods)? b: if not can it be added (perhaps with aka)?

You can do this as well:

include StupidlyLongLibName::LongModuleName

however it all stuff from the said module.

···

On 9/28/06, Kevin Jackson <foamdino@gmail.com> wrote:

Hi all,

Last night I was playing with some third-party lib and found myself
having to type StupidlyLongLibName::LongModuleName::LongClassName
repeatedly and I wanted a mechanism where I could rename these classes
for my own use to cut down on the finger typing.

I thought I could just do:

class Shortname < OldLongClassName; end

Unfortunately this didn't work (yes there's no error thrown, but the
later code expected OldLongClassName and wouldn't work with Shortname

So my request is:
a: is it possible to alias a class (I know you can do it with methods)?
b: if not can it be added (perhaps with aka)?

Note: depending on where in the code you are some of these do not really
make sense.

That's an amazingly intuitive comment - wish I'd made that /me == jealous...

Thanks for the rest of the insight, but this particular thing rings
true for just about any/all code

Kev

my favourite is

   d, f, fu = Dir, File, FileUtils

since those three go together in verbose code so often.

-a

···

On Thu, 28 Sep 2006, Robert Klemme wrote:

Kevin Jackson <foamdino@gmail.com> wrote:

So my request is:
a: is it possible to alias a class (I know you can do it with
methods)? b: if not can it be added (perhaps with aka)?

You can store that class in any variable or constant you like. So all of these work:

$cl = ::StupidlyLongLibName::LongModuleName::LongClassName
@cl = ::StupidlyLongLibName::LongModuleName::LongClassName
@@cl = ::StupidlyLongLibName::LongModuleName::LongClassName
cl = ::StupidlyLongLibName::LongModuleName::LongClassName
Cl = ::StupidlyLongLibName::LongModuleName::LongClassName

Note: depending on where in the code you are some of these do not really make sense.

--
in order to be effective truth must penetrate like an arrow - and that is
likely to hurt. -- wei wu wei

w00t! Forget all those silly "constants"!

    $d, $f, $fu = Dir, File, FileUtils

T.

···

ara.t.howard@noaa.gov wrote:

my favourite is

   d, f, fu = Dir, File, FileUtils

since those three go together in verbose code so often.

> my favourite is
>
> d, f, fu = Dir, File, FileUtils
>
> since those three go together in verbose code so often.

w00t! Forget all those silly "constants"!

    $d, $f, $fu = Dir, File, FileUtils

Much too readable

*x = Dir, File, FileUtils

who needs names!!!

Robert

T.

···

On 9/28/06, Trans <transfire@gmail.com> wrote:

ara.t.howard@noaa.gov wrote: