Both in Rebol and Red, there are two PARSE key words: break
and reject
which have similar behavior: break out of a match loop (such as any, some, while), the difference is that break
always indicating success while reject
indicate failure.
I know what it means literally, but can't figure out a proper scenario where which of the two keywords should be used.
blk: [ 1 #[none] 2 #[none] #[none] 4 5 6 #[none] ]
count: 0
result: parse blk [
any [
remove none! insert 2
if ((count: count + 1) >= 2) break
|
skip
]
]
probe blk ;will get [1 0 2 0 none 4 5 6 none]
probe result ;will get false
probe count ;will get 2
In the code above, either break
or reject
will produce the same result.
So anyone can show me what is the difference between these two keywords?