Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: index? none

From: carl:cybercraft at: 29-Nov-2002 9:16

On 29-Nov-02, Ted Landis wrote:
> Hi > How do I best avoid the error possible in the following: > index? find block x > When x is not in block it returns none and index? returns an error.
Hi Ted, Here's one way...
>> block: ["a" "b" "c"]
== ["a" "b" "c"]
>> if block? blk: find block "b" [index? blk]
== 2
>> if block? blk: find block "d" [index? blk]
== none or if you want a number returned instead of a none you could use...
>> either block? blk: find block "d" [index? blk][0]
== 0 Hope that helps. -- Carl Read