From: Sebastian Hungerecker Date: 2007-12-09T06:59:53+09:00 Subject: Re: .max a Block of code with yield? Wesley Rishel wrote: > require 'find' > Find.find (pth) { |x| yield(x)}.max > > giving the error no block given (LocalJumpError), which I interpret as > saying the yield doesn't know to yield to max. yield(x) means: "Execute the block that has been given to this method with the parameter x". You can't yield to methods. Especially since the max won't start executing before the find is finished executing. > It is possible that this is equivalent to asking if there is a way to > feed the output of an iterator into somthing that is looking for the the > .each iterator of an enum. That's possible using to_enum. To enum from the enumerator library (which is part of stdlib) can be called on any object and turns it into an enum by taking the method given as a parameter as an replacement for each. E.g.: require 'find' require 'enumerator' Find.to_enum(:find,pth).max Or you could just use Dir[] instead of Find.find, which returns an array which is enumerable by default. Like Dir["/my/path/**/*"].max HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826