Tony Arcieri wrote: > On Wed, Nov 4, 2009 at 1:46 PM, Marnen Laibow-Koser > <marnen / marnen.org>wrote: > >> This is unidiomatic Ruby. In fact, it's becoming clear to me that just >> about *any* use case for postfix ++ is unidiomatic Ruby. The cleanest >> way *in Ruby* of doing what you did would be >> >> (1..10).each {|i| puts i} >> >> Incrementing is handled under the hood. >> > > What if it's not? > > m = CounterInMemcacheOrSomething.new :foobar > m++ What semantics do you intend here? I'm not sure I understand. In any case, you have several perfectly good alternatives: * use CounterInMemcacheOrSomething.all(:foobar).each{|m| ...} * define CounterInMemcacheOrSomething#succ! if it's mutable * or even use m += 1 ++ is very useful in C-like languages and PHP. I thought it would be useful in Ruby too, but I now believe that it wouldn't, since it's only really good for stepping through structures -- and Ruby handles that better with iterators. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen / marnen.org -- Posted via http://www.ruby-forum.com/.