From: David Vallner Date: 2006-02-13T05:32:01+09:00 Subject: Re: ruby course confusion Dňa Nedeľa 12 Február 2006 21:16 Alex Combas napísal: > On 2/11/06, Matthew Smillie wrote: > > Thanks Matthew, I appreciate you taking the time > to reword this for me, but there is one part that is > still bothering me. > > > > The block should take two parameters and return a boolean value. > > Its the thing with the boolean that I dont get. This seems to be asuming > some prior knowledge of a particular ruby method. > I've searched Array and String and dont see anything that fits. > > What is this boolean supposed to show? Booleans can me on/off > true/false, found/not_found, or many other things. > > If the guide just stated what the boolean is for, or even better what > method they want used that returns a boolean I'm sure this would > be a rather simple problem. > > Finding the longest or shortest string in an array is so trivial. > This really seems more like an exercise on howto structure blocks > and pass variables to methods. D'oh. What I think are strong hints follows. Don't read this mail if you don't want any. I think the block should be a predicate that defines if something was "found" - that's what the boolean it returns should tell. Or rather evaluate if an element is more "it" than the previous one found. As for the two parameters, I think one should be an element from the array that's being iterated on, and another the last element for which the block returned true. Let Enumerable#inject be an inspiration, I believe #find_it is supposed to have similar swissknifeitude. (Groan) Alright, but I'm getting dangerously close to giving away complete spoilers, so I'll leave you some challenge to the problem. David Vallner