[REBOL] Re: IDIOMS: setting multiple words
From: SunandaDH:aol at: 9-Oct-2003 16:05
Hi Gregg,
> foo: copy []
> bar: copy []
> baz: copy []
>
> Or like this?
>
> foreach word [foo bar baz][set word copy []]
>
> Or something else.
>
I'd go for the first way -- that way I can easily change my mind if I need to
set 'bar to something else.
If you are going to use set, you could use a shorter method:
set [foo bar baz] copy []
Another method you will see around is:
foo: bar: baz: copy []
To all your other questions: I'd take a tactical approach if I had lots more
fields, or something special was indicated.
I've very occasionally had to extend a function that returned a single value
to return more than one value. Set is a quick hack in that case:
my-func: func [] [return [1 2]]
set [a b] my-func
Sunanda