Project

General

Profile

Actions

Misc #3401

closed

arrays containing them selves do not apply == sensibly.

Added by dmt10 (Dominic Tarr) almost 14 years ago. Updated about 13 years ago.

Status:
Rejected
Assignee:
-
[ruby-core:30628]

Description

=begin
a = [:a]
a << a
puts a
=> [:a [...]]

b = [:a]
b << b
puts b
=> [:a [...]]

#so , a == b?
puts a == b
=> false

#but they have the same structure...
puts a.to_yaml == b.to_yaml
=> true

#it looks like == compares the object_id's of arrays within arrays.
#more evidence:

c = [:a]
c << a
puts c
=> [:a, [:a, [...]]]
#clearly, a distinctly different array.
puts a == c
=> true
puts a.to_yaml == c.to_yaml
=> false

#this seems surprising behaviour to me
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0