[MacRuby-devel] Comparison between String and nil fails.

Laurent Sansonetti lsansonetti at apple.com
Wed May 5 13:36:16 PDT 2010


Hi Michel,

Thanks for the report. Thibault reduced the problem, we will track it here:

https://www.macruby.org/trac/ticket/690

Laurent

On May 5, 2010, at 2:11 AM, Michel Steuwer wrote:

> Hi everyone,
> yesterday i migrated my little MacRuby project to 0.6 and i found a kind of strange behavior in a comparison between a string and nil. In MacRuby 0.5 the line worked as expected.
> I get the following error message in a comparison between a string on the left and nil on the right:
> can't convert nil into String (TypeError)
> 
> I made a little demo project to show the problem.
> The string i want to compare comes out of a userInfo dictionary i get when iTunes send a notification through the NSDistributredNotificationCenter.
> In the demo project the error occurs, if you play, pause, or skip a song in iTunes (every time i get a notification from iTunes).
> 
> So here the code in which the error occurs:
> 
> def songChanged(notification)
> 	NSLog("notification.userInfo[Name]		#{notification.userInfo['Name']}.")
> 	NSLog("notification.userInfo[Name].nil?		#{notification.userInfo['Name'].nil?}.")
> 	NSLog("notification.userInfo[Name].class	#{notification.userInfo['Name'].class}.")
> 	NSLog("notification.userInfo[Name] != nil	#{notification.userInfo['Name'] != nil}")
> end
> 
> The method receives a notification from iTunes and the last line in the method fails ( notification.userInfo['Name'] != nil ).
> 
> I don't know where the problem is, but i guess the comparison should just return false. One again, in MacRuby 0.5 the line worked as expected.
> 
> You can find the hole demo project at:
> http://github.com/michelSt/MacRubyBug
> 
> Thanks,
> Michel
> --
> Michel Steuwer     |     michel.steuwer at onlinehome.de
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100505/e836d665/attachment.html>


More information about the MacRuby-devel mailing list