On Thu, Aug 07, 2003 at 11:17:13PM +0900, KONTRA Gergely wrote:
> So questions in general:
> How can I alter items in a hash nicely?

         h[key] = value           # replace it
         h[key] << value          # append to existing array

> Can I exit more loops with next/last/redo? (like in perl)

If you want to exit out of more than one level, use catch/throw.
[you mean next/break/redo I think]

> Is there something similar to python's for .. else ... structure? (Do
> something, ONLY when the loop is terminated normally (without break)

Hmm, I don't understand - why not just put the code at the end of the block?
If you haven't done a 'break' or 'next' then it will be executed.

You might be able to use begin ... ensure ... end; the ensure section is
*always* executed.

irb(main):008:0> 5.times { begin puts "x"; break; ensure puts "y"; end }
x
y
=> nil


Regards,

Brian.