REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 16-Aug-2010 Edit History  

REBOL 3 Functions: until

until  block

Evaluates a block until it is TRUE.

Arguments:

block [block!]

See also:

while   repeat   loop   foreach   for  

Description

The until function evaluates a block until the block returns true. It is different from while because it only requires a single block, which also serves as the condition. However, the block is always evaluated at least once.

The general form is:

while [cond] [body]

For example:

num: 0
until[
    print num
    num: num + 1
    num >= 2
]
0
1
2

Another example:

str: "test"
until [
    print str
    tail? str: next str
]
test
est
st
t

Return Value

The last value of the block is returned from the until function. Because this is also the termination condition, it will always be non-none non-false, but that can be useful at times.

Other Notes


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin