From: Robert Klemme Date: 2006-07-07T05:07:12+09:00 Subject: Re: A newbie would like some code criticism, please... 2006/7/6, Elliot Temple : > > i'm not happy with the suggested solutions. i think the inject > solution is OK when it works, and next best is each_with_index. but i > think worrying about indexes is too low level when we don't actually > want to deal with numbers. it's worse when you care about the last > iteration and have to worry about off-by-one errors (you need to do > something special on list.length-1) what might be nicer is either > variable capture in loops (i guess that is rejected because it's too > confusing?) or each_with_first_last (with a shorter name). You might want to search the archives of ruby-talk - IIRC we had several lenghty discussions about these kind of problems. I personally didn't yet need these. And if, the boolean toggle is ok for me. Cheers robert -- Have a look: http://www.flickr.com/photos/fussel-foto/