Rebol Programming/default

From Wikibooks, open books for an open world
< Rebol Programming
Jump to navigation Jump to search

USAGE:[edit | edit source]

DEFAULT 'word value 

DESCRIPTION:[edit | edit source]

Set a word to a default value if it hasn't been set yet.

DEFAULT is a function value.

ARGUMENTS[edit | edit source]

  • word -- The word (use :var for word! values) (Type: word set-word lit-word)
  • value -- The value (Type: any)

SOURCE CODE[edit | edit source]

default: func [
    {Set a word to a default value if it hasn't been set yet.} 
    'word [word! set-word! lit-word!] "The word (use :var for word! values)" 
    value "The value"
][
    unless all [value? word not none? get word] [set word :value] :value
]