Re: ruby1.9 and the retry keyword
- From: Yoann Guillot <john-rubytalk@xxxxxxxx>
- Date: Sun, 19 Apr 2009 13:17:54 -0500
On Mon, Apr 20, 2009 at 02:10:33AM +0900, James Gray wrote:
On Apr 19, 2009, at 12:01 PM, Christopher Dicely wrote:
That mimics the example (where the retry is unconditional), but
clearly isn't a general solution;
I'll be surprised if more complex examples can't be similarly converted
fairly easily. That was kind of my point. I meant the code to say, take
a step back and think what is this trying to do?
My code walks an array, and may change the current element, which is allowed
without breaking the iteration.
I have also a special case where i have to change a whole subsection of the
array, this was the case where i used 'retry'
eg
ary.each { |e|
case e
when foo
ary[ary.index(e)] = foo(e)
when bar
when ...
when baz
ary[ary.index(e), 12] = [flublu]
retry
end
}
Sure, i could use map or many other ways, my code is quite ugly anyway.
I was just surprised by the change of behavior.
I don't see the point in removing capabilities from the language (restarting
an iteration from within), but I can sure live with it.
--
Yoann
.
- Follow-Ups:
- Re: ruby1.9 and the retry keyword
- From: Sean O'Halpin
- Re: ruby1.9 and the retry keyword
- From: James Gray
- Re: ruby1.9 and the retry keyword
- References:
- ruby1.9 and the retry keyword
- From: Yoann Guillot
- Re: ruby1.9 and the retry keyword
- From: James Gray
- Re: ruby1.9 and the retry keyword
- From: Christopher Dicely
- Re: ruby1.9 and the retry keyword
- From: James Gray
- ruby1.9 and the retry keyword
- Prev by Date: Re: ruby1.9 and the retry keyword
- Next by Date: Re: ruby1.9 and the retry keyword
- Previous by thread: Re: ruby1.9 and the retry keyword
- Next by thread: Re: ruby1.9 and the retry keyword
- Index(es):
Relevant Pages
|