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

[REBOL] Re: Binding

From: brett:codeconscious at: 21-Nov-2002 11:42

> ;Why doesn't this return which language the greeting is in? > > m: func [instance] [for index 1 4 1 [if s-c? [instance pick > instances-of-greeting index] pick languages index] ] > > m i
There are some coding errors in this. The the brackets are around the IF condition instead of the body block of the IF. Also, once the IF condition becomes true you should RETURN the result immediately rather than continuing the search. If you don't use the RETURN function then the code would return the result of the IF when index = 4, if there was a match you get right the result, if there was no match then you would get NONE. Finally you need to pass the M function one of these word instances. If changed your code as described: m: func [instance] [ for index 1 4 1 [ if s-c? instance pick instances-of-greeting index [ return pick languages index ] ] ] m 'greeting a-greeting-word: in france 'greeting m a-greeting-word Regards, Brett.