Hey,

I wrote a line of code that I thought was correct (but maybe not so pretty) and 
in one case it was giving me a weird error. I was wondering if someone could 
explain to me what is wrong with it; I suspect there is some behaviour of 
MacRuby that I am not understanding. Here are a few examples that are close to 
what I had:

A working case: (Case #1)

        require 'uri'
        test = URI.parse url unless (url = nil).nil? # works, as I expected, 
url is nil and the left side is not evaluated


Ok, try again, but without a nil value for url: (Case #2)

        require 'uri'
         test = URI.parse url unless (url = 'http://macruby.org/').nil?  # 
error about url not being defined


Now, when I try this out in macirb: (Case #3)

        require 'uri'
         test = URI.parse url unless (url = 'http://macruby.org/').nil?  # 
error again

         test = URI.parse url unless (url = 'http://wikipedia.org/').nil? # 
works fine this time

        puts test.to_s  # gives me the wikipedia value


If it doesn't work in the second case, why does it start working in the third 
case?

Thanks,
        Mark

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to