Dynamic object creation

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Regards,

Dan

···

-----Original Message-----
From: ts [mailto:decoux@moulon.inra.fr]
Sent: Friday, July 26, 2002 9:20 AM
To: ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org
Subject: Re: dynamic object creation

m = “TestClass”
require “#{m}”
t = eval “#{m}.new”

eval is evil

pigeon% cat TestClass.rb
class TestClass
end
pigeon%

pigeon% cat b.rb
#!/usr/bin/ruby
m = “TestClass”
require m
p Object.const_get(m).new
pigeon%

pigeon% b.rb
#TestClass:0x401af914
pigeon%

Guy Decoux

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Because “There’s More Than One Way To Do It”. :slight_smile:

Regards,

Dan

    Hugh
···

On Fri, 26 Jul 2002, Berger, Daniel wrote:

Hi –

···

On Sat, 27 Jul 2002, Hugh Sasse Staff Elec Eng wrote:

On Fri, 26 Jul 2002, Berger, Daniel wrote:

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Because “There’s More Than One Way To Do It”. :slight_smile:

Hmmm… interesting cause-effect conundrum: Is there Perl because
there’s more than one way to do it, or is there “There’s More Than One
Way To Do It” because there’s Perl?

:slight_smile:

David


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav