Right now for custom objects on the Objective-C side even if you provide a -[Object description] call to_s will fall through and hit to_s from NSObject which right now just has the class name and pointer. Is it already planned for the future to use the description method in to_s on the MacRuby side? Should I file a bug report? Jordan
Jordan, you can do something like that: class Object alias :old_inspect :inspect def inspect i = old_inspect if i.start_with?('#<') d = description d.start_with?('<') ? i : d else i end end end But you’re right, a better integration of „description“ would be nice. Bernd Am 05.05.2010 um 22:30 schrieb Jordan Breeding:
Right now for custom objects on the Objective-C side even if you provide a -[Object description] call to_s will fall through and hit to_s from NSObject which right now just has the class name and pointer.
Is it already planned for the future to use the description method in to_s on the MacRuby side? Should I file a bug report?
Jordan_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Yeah, I was doing something similar right now, just hoping for a better long term solution in MacRuby. On May 05, 2010, at 20:11, B. Ohr wrote:
Jordan,
you can do something like that:
class Object alias :old_inspect :inspect
def inspect i = old_inspect if i.start_with?('#<') d = description d.start_with?('<') ? i : d else i end end end
But you’re right, a better integration of „description“ would be nice.
Bernd
Am 05.05.2010 um 22:30 schrieb Jordan Breeding:
Right now for custom objects on the Objective-C side even if you provide a -[Object description] call to_s will fall through and hit to_s from NSObject which right now just has the class name and pointer.
Is it already planned for the future to use the description method in to_s on the MacRuby side? Should I file a bug report?
Jordan_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Jordan, Yes please file a bug report, this looks like a nice enhancement. Thanks, Laurent On May 5, 2010, at 1:30 PM, Jordan Breeding wrote:
Right now for custom objects on the Objective-C side even if you provide a -[Object description] call to_s will fall through and hit to_s from NSObject which right now just has the class name and pointer.
Is it already planned for the future to use the description method in to_s on the MacRuby side? Should I file a bug report?
Jordan_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
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“))
Hi, On May 8, 2010, at 5:02 AM, B. Ohr wrote:
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????????
Nope, looks like you found a bug. Could you report that in the tracker? As a workaround, you can create the hash object using `NSMutableDictionary.dictionary'. Laurent
participants (3)
-
B. Ohr
-
Jordan Breeding
-
Laurent Sansonetti