Bug #961
closeda bug or a missleading documentation for Singleton module
Description
=begin
require 'singleton'
class Klass
include Singleton
# ...
end
a,b = Klass.instance => [#Klass:0xebaf12]
b #=> nil
####################
in http://www.ruby-doc.org/stdlib/libdoc/singleton/rdoc/index.html
a == b # => true¶
is that a bug or missleading documentation ???¶
###################
=end
Updated by murphy (Kornelius Kalnbach) almost 16 years ago
=begin
I guess it should be
a = Klass.instance
b = Klass.instance
a == b # => true
If you look exactly, there are two Klass.instance on the right side - a multi-assignment. So the documentation is correct, but likely to be misunderstood by beginners.
=end
Updated by matz (Yukihiro Matsumoto) almost 16 years ago
=begin
Hi,
In message "Re: [ruby-core:21029] [Bug #961] a bug or a missleading documentation for Singleton module"
on Thu, 1 Jan 2009 07:01:36 +0900, khaled alhabache redmine@ruby-lang.org writes:
|# in http://www.ruby-doc.org/stdlib/libdoc/singleton/rdoc/index.html
|# a == b # => true
|# is that a bug or missleading documentation ???
The text in the above document said (with properly formatted):
a,b = Klass.instance, Klass.instance
a == b # => true
a.new # NoMethodError - new is private …
Your input was:
|a,b = Klass.instance # => [#Klass:0xebaf12]
|b #=> nil
Now you can see the difference. You've typed single Klass.instance.
It apparently not a bug. You misread it, maybe because of missing
newlines in text from ruby-doc.org. I probably caused by missing
indentation in RDoc in signleton.rb. I will fix this.
matz.
=end
Updated by mernen (Daniel Luz) almost 16 years ago
=begin
a,b = Klass.instance, Klass.instance
a == b # => true
a.new # NoMethodError - new is private …
Also, shouldn't the last line say "Klass.new"?
=end
Updated by matz (Yukihiro Matsumoto) almost 16 years ago
=begin
Hi,
In message "Re: [ruby-core:21038] [Bug #961] a bug or a missleading documentation for Singleton module"
on Thu, 1 Jan 2009 20:10:06 +0900, Daniel Luz redmine@ruby-lang.org writes:
| a.new # NoMethodError - new is private …
|
|Also, shouldn't the last line say "Klass.new"?
Indeed. I will fix.
matz.
=end
Updated by ko1 (Koichi Sasada) almost 16 years ago
- Status changed from Open to Closed
- Assignee set to matz (Yukihiro Matsumoto)
- ruby -v set to 1.9
=begin
=end