On 0807, Brian Candler wrote:
> 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

Oops. Sorry. The question was dumb. I mean: I want to iterate over a
hash and change some elements. (in perl you get the elements, not copys
of the elements.

> > 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]
Yes, this works, but is there any exception? Wouldn't it be confusing?

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

Eg. suppose I want to search for value in array
If it would be a for .. else .. end construction in ruby, I could write:

for element in array
  if element==value
    puts "#{element} found in array!"
    break
  end
else
  puts "#{element} not found in array"
end


But ts showed, that a loop returns nil, if I use break without a
parameter. (if I'm right...)

Gergo
-- 
+-[ Kontra, Gergely<kgergely / mcl.hu> PhD student Room IB113 ]---------+
| http://www.mcl.hu/~kgergely            "Olyan langesz vagyok, hogy  |
| Mobil:(+36 20) 356 9656 ICQ: 175564914   poroltoval kellene jarnom" |
+-- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+