Project

General

Profile

Actions

Bug #961

closed

a bug or a missleading documentation for Singleton module

Added by khelll (khaled alhabache) almost 14 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
ruby -v:
1.9
[ruby-core:21029]

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

Actions #1

Updated by murphy (Kornelius Kalnbach) almost 14 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

Actions #2

Updated by matz (Yukihiro Matsumoto) almost 14 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 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

Actions #3

Updated by mernen (Daniel Luz) almost 14 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

Actions #4

Updated by matz (Yukihiro Matsumoto) almost 14 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 writes:

| a.new # NoMethodError - new is private …
|
|Also, shouldn't the last line say "Klass.new"?

Indeed. I will fix.

						matz.

=end

Actions #5

Updated by ko1 (Koichi Sasada) almost 14 years ago

  • Status changed from Open to Closed
  • Assignee set to matz (Yukihiro Matsumoto)
  • ruby -v set to 1.9

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0