1
Vote

IEnumerator support

description

Should support treating an IEnumerator as a Ruby Enumerable, just as we do with IEnumerable.
 
Reported by Doug Blank doug.blank@gmail.com:
public static IEnumerator getPixels(Picture picture) {
   for (int x=0; x < picture.width; x++) {
     for (int y=0; y < picture.height; y++) {
         yield return picture.getPixel(x, y);
     }
   }
 }
}

I can call this fine in IronPython:

for pixel in getPixels(pic):
   r, g, b = getRGB(pixel)
   gray = (r + g + b)/3
   setRGB(pixel, gray, gray, gray)

But I don't see how to call this from IronRuby:

Myro::getPixels(pic) do |pixel|
   r, g, b = Myro::getRGB pixel
   gray = (r + g + b)/3
   Myro::setRGB(pixel, gray, gray, gray)
end

All I get back is Myro+<getPixels>c__Iterator0.

comments