* Ryan Gahl wrote (07/09/06 17:53): > As far as "providing more meaning"... you're simply skinng the same cat > another way. Not sure how much "meaning" you can give to a loop by doing > way X instead of way Y. The meaning of the loop is still the same :-)
I personally don't really like the solution using each(), because it relies on the generation of a sequence of numbers that is a bit obscure. The same goes for the times() solution. Neither of those functions seems to be designed primarily with counting in mind. [The times function is mainly a wrapper for the each function anyway]. But that's just me, and I'll probably change my mind tomorrow. > > But yes, your way is great as well. I was really just trying to shed > some light on the reasons why the OP's (and my) original ways weren't > working, so was avoiding the prototype magic. Perhaps I can bring some closure to the closure discussion with the attached test page. Put it somewhere where it can reach prototype.js, and play with the onload="runX()" to see what happens. I had to fix Brandon's and Eric's solutions slightly, because each() and times() use zero-based counters (and 5.times gives a js parse error). I think the article on closures Matt linked to is probably as good as you're likely to get in terms of actually explaining it all. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
one
two
three
four
five
