Does anyone know why I am getting this warning?
$ ruby -v
ruby 1.8.0 (2003-04-11) [i686-linux]
$ cat atest.rb
require ‘singleton’
class X
include Singleton
end
X.instance
$ ruby -w atest.rb
/usr/local/lib/ruby/1.8/singleton.rb:145: warning: redefine instance
$
Thanks
± S.D.Sykes - www.stephensykes.com -
ruby -e ‘_=2;"||25~!A59(1A~47!K~#-6<.A~".scan(/./){
putc$&>$`?$/:+=$&[0]-?4}’
jbshaldane@hotmail.com (haldane) wrote in message news:7762c743.0304172306.1c4374b8@posting.google.com…
Does anyone know why I am getting this warning?
$ ruby -v
ruby 1.8.0 (2003-04-11) [i686-linux]
$ cat atest.rb
require ‘singleton’
class X
include Singleton
end
X.instance
$ ruby -w atest.rb
/usr/local/lib/ruby/1.8/singleton.rb:145: warning: redefine instance
$
Just to clarify my question a little, the warning comes from this line
in singleton.rb (just after the instance has been created):
def self.instance() @instance end
Is there any reason it could not be replaced with
define_method(:instance, proc { @instance })
which does not result in the warning?
Thanks
± S.D.Sykes - www.stephensykes.com -
ruby -e ‘_=2;"||25~!A59(1A~47!K~#-6<.A~".scan(/./){
putc$&>$`?$/:+=$&[0]-?4}’
Hi Matz,
Just to clarify my question a little, the warning comes from this line
in singleton.rb (just after the instance has been created):
def self.instance() @instance end
Is there any reason it could not be replaced with
define_method(:instance, proc { @instance })
which does not result in the warning?
Nice idea, thank you.
I noticed you changed singleton.rb, but you only changed the code on
line 159 - I think you also need to change line 145 to match.
Regards
± S.D.Sykes - www.stephensykes.com -
···
“This may seem a bit weird, but that’s okay, because it
is weird.” – Programming Perl on variable name prefixes