[MacRuby-devel] 0.7 problems with complex index in a hash
B. Ohr
jazzbox at 7zz.de
Sat May 8 05:02:29 PDT 2010
Hi,
v0.7 has a different behavior than v0.5 when using a Cocoa-Obj (NSCalendarDate) as a key in a hash.
I must admit that I do not know what is exactly specified in Ruby, but obviously the generated value of an hashkey of different objects is same in all other cases if the objects itself are identical:
- Bernd
---
$ macruby_select 0.7 h.rb
{#<NSCalendarDate:0x2000df2a0>=>:x, #<NSCalendarDate:0x2000c7fa0>=>:y} # <==== is this ok????????
{["t", "e", "s", "t"]=>:y}
{#<Date: 2010-02-01 (4910457/2,0,2299161)>=>:y}
$ macruby_select 0.5 h.rb
{#<NSCalendarDate:0x2000a3280>=>:y}
{["t", "e", "s", "t"]=>:y}
{#<Date: 2010-02-01 (4910457/2,0,2299161)>=>:y}
$ ruby h.rb
{["t", "e", "s", "t"]=>:y}
{#<Date: 4910457/2,0,2299161>=>:y}
$ ruby1.9 h.rb
{["t", "e", "s", "t"]=>:y}
{#<Date: 2010-02-01 (4910457/2,0,2299161)>=>:y}
$ cat h.rb
require 'Date'
def h(d1,d2)
h = { d1 => :x}
h[d2] = :y
p h
end
d1 = NSCalendarDate.dateWithYear( 2010, month:5, day:2, hour:0, minute:0, second:0, timeZone:nil)
d2 = NSCalendarDate.dateWithYear( 2010, month:5, day:2, hour:0, minute:0, second:0, timeZone:nil)
h(d1,d2)
h( ["t", "e", "s", "t"],"test".chars.to_a)
h( Date.parse("2010-02-01"), Date.parse("2010-02-01“))
More information about the MacRuby-devel
mailing list