[MacRuby-devel] Bizarre behaviour with an instance variable

Martin Hawkins martin.hawkins at gmail.com
Thu Jan 27 01:18:16 PST 2011


I find the following behaviour a little bizarre:
At the macirb prompt (0.8)
fileManager = NSFileManager.defaultManager
@theProjectRoot = '/Users/martin/work/macruby/lots_of_files'
=> "/Users/martin/work/macruby/lots_of_files"
>> filenames = fileManager.contentsOfDirectoryAtPath(@theProjectRoot, error:nil).map {|f| theProjectRoot.stringByAppendingPathComponent(f) }
NameError: undefined local variable or method `theProjectRoot' for
main:TopLevel

If I create a local variable with the name theProjectRoot, then the
statement runs correctly. According to the documentation,
NSFileManager.defaultManager.contentsOfDirectoryAtPath requires a
string; the scope of the variable should be irrelevant, shouldn't it?



More information about the MacRuby-devel mailing list