[MacRuby] #1381: Calling objective-c method with semicolon before 1st arg sometimes works
MacRuby
ruby-noreply at macosforge.org
Mon Aug 22 18:00:34 PDT 2011
#1381: Calling objective-c method with semicolon before 1st arg sometimes works
--------------------------------+-------------------------------------------
Reporter: sohocoke@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords:
--------------------------------+-------------------------------------------
Comment(by sohocoke@…):
Sorry for the formatting. Here it is again:
{{{
[ilo-robbie at nibbler:~]$ macirb -f
# demonstrate flexible syntax
irb(main):002:0> s1 = NSString.stringWithString("hi")
=> "hi"
irb(main):003:0> s2 = NSString.stringWithString:"hi"
=> "hi"
# some other weirdness observed during equality tests using objective-c
methods - didn't have time to look into this, could be related
irb(main):004:0> s1.isEqual:s2
=> 0
irb(main):005:0> s1.isEqualToString:s2
=> 0
irb(main):006:0> s1 == s2
=> true
irb(main):007:0> s1.isEqual(s2)
=> 1
# demonstrate normal operation
irb(main):009:0> p1 = "/tmp/macruby-file"
=> "/tmp/macruby-file"
irb(main):010:0> `ls #{p1}`
ls: /tmp/macruby-file: No such file or directory
=> ""
irb(main):018:0> framework 'cocoa'
=> true
irb(main):019:0> s1.writeToFile(p1, atomically:true,
encoding:NSUTF8StringEncoding, error:nil)
=> true
irb(main):020:0> `ls #{p1}`
=> "/tmp/macruby-file\n"
irb(main):021:0> `rm #{p1}; ls #{p1}`
ls: /tmp/macruby-file: No such file or directory
=> ""
# demonstrate weird operation when using flexible syntax
irb(main):022:0> s1.writeToFile:p1, atomically:true,
encoding:NSUTF8StringEncoding, error:nil
=> true
irb(main):023:0> `ls #{p1}`
ls: /tmp/macruby-file: No such file or directory
=> ""
# i'm going to guess that the symbol :p1 got passed to the call.
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/1381#comment:1>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list