From: MikkelFJ Date: 2002-12-01T05:59:39+09:00 Subject: Re: Ruby ++, the one element and generators "MikkelFJ" wrote in message news:3de91a9b$0$47402$edfadb0f@dtext01.news.tele.dk... > if my_collection.size > 1 > begin > c = 0 > a = my_collection.first > k = a > ++a > while a != my_collection.end > b = a > a++ > if a.value > b.value > a.swap_values b > c++ > end > end while c > 0 > end In the above I was a bit loose on the semantics of a++ vs. ++a. These semantics should be well known - i.e. return the old vs. returning the new value: ++a <=> return a = a.next a++ <=> b = a; a = a.next; return b Clearly this doesn't make sense for ++! because we are destroying the old value. One solution would be to disallow a++!, and only allow ++!a, another solution would be to to conclude that a is still referencing the same object so the old value is the same as the new value, thus ++!a <=> a++! I'd prefer the latter solution, although I can hardly imagine anyone writing ++!a. Mikkel