[MacRuby-devel] rubyfying Cocoa iterators

Mateus Armando seanlilmateus at googlemail.com
Wed Nov 16 11:38:58 PST 2011


this should work, you can still use enumerateIndexesUsingBlock!

framework 'Foundation'
class NSIndexSet
  def each
    return self.to_enum unless block_given?
    self.enumerateIndexesUsingBlock -> idx, stop { yield idx }
  end
end



indexes = NSIndexSet.indexSetWithIndexesInRange NSMakeRange(0, 300)
indexes.each do |idx|
  puts idx
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20111116/ea094682/attachment-0001.html>


More information about the MacRuby-devel mailing list