Aller au contenu principal

both

Return the list of keys and values of a context.

BOTH

NAME

both - Returns the list of keys and values of a context.

SYNOPSIS

both(variable);

DESCRIPTION

This function is used to return the list of keys and values of a context as a cotext. A context is an array in which instead of using numbers you use characters strings. Key contains the key name and, obviously, value contains the value. These are elements associated with the ones defined at the beginning(the keys).

If it is used as a function, it returns the list as an array.

If it is used as a callback, it returns each keys.

PARAMETERS

Variable
Specifies a variable of type context to list the keys and values.

RETURN

Array
An array of all keys and values if used as a function or each keys on a loop.

EXAMPLES

res={{ for i both({x:1,y:2}) do i; endfor; }}. return res={"key":"x","value":1}{"key":"y","value":2}.
res={{ for i both({x:[1,3],y:{a:2,b:"4"}}) do i; endfor; }}. return res={"key":"x","value":[1,3]}{"key":"y","value":{"a":2,"b":"4"}}.
res={{ a={x:1,y:2}; for i both(a) do i; endfor }}. return res={"key":"x","value":1}{"key":"y","value":2}.
res={{ a={}; for i both(a) do i; endfor }}. return res=.
res={{ for i both({}) do i; endfor }}. return res=.
res={{ for i both(123) do i; endfor }}. return .*is not a context.*

res={{ both({x:1,y:2}); }}. return res=[{"key":"x","value":1},{"key":"y","value":2}].
res={{ a={x:1,y:2}; both(a); }}. return res=[{"key":"x","value":1},{"key":"y","value":2}].
res={{ both({}); }}. return res=[].
res={{ both(123); }}. return .*is not a context.*
res={{ a={x:[1,3],y:{a:2, b:4}}; both(a); }}. return res=[{"key":"x","value":[1,3]},{"key":"y","value":{"a":2,"b":4}}].

SEE ALSO

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.