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

REBOL 3 Functions: set

set  word  value  /any  /pad

Sets a word, path, block of words, or object to specified value(s).


word [any-word! any-path! block! object!] - Word, block of words, path, or object to be set

value [any-type!] - Value or block of values


/any - Allows setting words to any value, including unset

/pad - For objects, if block is too short, remaining words are set to NONE

See also:

get   in   value?   unset   protect   unprotect  


If the first argument is a block of words and the value is not a block, all of the words in the block will be set to the specified value. If the value is a block, then each of the words in the first block will be set to the respective values in the second block. If there are not enough values in the second block, the remaining words will be set to NONE

The /ANY refinement allows words to be set any datatype including those such as UNSET! that are not normally allowed. This is useful in situations where all values must be handled.

set 'test 1234
print test
set [a b] 123
print a
print b
set [d e] [1 2]
print d
print e

You can also use set-word! within the set function:

set [a: b:] [1 2]

This is useful if you use the funct function, which auto-detects local variables that use the set-word notation.

  TOC < Back Next > - WIP Wiki Feedback Admin