Default()

From TinyMUX
Revision as of 11:21, 27 November 2010 by Ihavenomouth (talk | contribs) (New page: Category:Functions {{Function|default(<obj>/<attr>,<default case>)}} This function returns the value of <obj>/<attr>, as if retrieved via the get() function, if the attribute exists ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


default(<obj>/<attr>,<default case>)

This function returns the value of <obj>/<attr>, as if retrieved via the get() function, if the attribute exists and is readable by you. Otherwise, it evaluates the default case, and returns that. Note that the default case is only evaluated if the attribute does not exist or cannot be read.

This is useful for code that needs to return the value of an attribute, or an error message or default case, if that attribute does not exist.

Example

> &TEST me=apple orange banana

> say default(me/Test, No fruits!)

You say, "apple orange banana"


> &TEST ME

> say default(me/Test, No fruits!)

You say, "No fruits!"

Related Topics

get(), get_eval(), u(), edefault(), udefault()