Aller au contenu principal

keys

Return the list of keys of a context.

KEYS

NAME

keys - Returns the list of keys of a context.

SYNOPSIS

keys (variable);

DESCRIPTION

This function is used to return the list of keys of a context. A context is a table with its elements indexed with a characters string. Each element of the context is related to a key.

If it is used as a function, it will return the list of keys as an array.

If it is used as a callback, it will return each key.

PARAMETERS

variable
Specifies a variable of type context to list the keys

RETURN

An array of all keys if used as a function or each keys on a loop

EXAMPLES

res={{ for i keys({x:1,y:2}) do i; endfor; }}. return res=xy.
res={{ a={x:1,y:2}; for i keys(a) do i; endfor }}. return res=xy.
res={{ a={}; for i keys(a) do i; endfor }}. return res=.
res={{ for i keys({}) do i; endfor }}. return res=.
res={{ for i keys(123) do i; endfor }}. return .*is not a context.*

res={{ keys({x:1,y:2}); }}. return res=["x","y"].
res={{ a={x:1,y:2}; keys(a); }}. return res=["x","y"].
res={{ keys({}); }}. return res=[].
res={{ keys(123); }}. return .*is not a context.*

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.