Hi,

I agree with Robert. Of course both ways work and the first may even be 
a bit more efficient. But it's definitely a kind of hack, because you're 
"misusing" the instance variables.

Also you will get an exception when you call "last" before having called 
"first" before. Since you cannot even know this without looking at the 
method definition, the whole code is rather obscure. You're relying on 
certain outer condiditions, which have nothing to do with the actual 
task (returning a simple string).

I think it's generally a good idea to avoid implicit values (global 
variables etc.) as much as possible and try to encapsulate 
functionalities.

-- 
Posted via http://www.ruby-forum.com/.