Hi all,

this is another possibility:

items:  [1 2 3 4 5 6 7 8 9]
foreach i items [
 catch [
  print i
  if i // 2 = 0 [throw]
  print ["  " i "is odd"]
 ]
]

rgeards,

Cyphre

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 17, 2005 9:24 AM
Subject: [REBOL] Re: Iterations question


>
> Albert:
>
> > Is there a way to force the next iteration within loops?
>
> One way is to wrap a loop 1 around the loop and then use break to exit the
> loop 1.
>
> foreach item [1 2 3 4 5 6 7 8 9] [
>    loop 1 [
>        print item
>        if item // 2 = 0 [break]
>        print ["  " item "is odd"]
>        ]
>    ]
>
> Though in many cases refactoring the code may lead to a more elegant
> structure.
>
> Sunanda.
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to