From: "Simon Kröger" Date: 2005-08-09T05:25:34+09:00 Subject: Re: polymorphism and/or named parameters: the ruby way? >>This very useful little method is a nice thing to have in your >>bag-o-tricks. > > Nice. you could even call it #then: > > class Object > def then > yield(self) > self > end > end > > #Then you could do these types of things: > a = (0..10).to_a > i = 3 > p a[i.then{i+=1}] > p i > > [..snip..] But be carefull: i = 3 p i.then{i+=1} p i i = [3] p i.then{i << 4} p i output: 3 4 [3, 4] [3, 4] (perhaps this was obvious to all, except me) cheers Simon