function

keys . context . sncode

VERSIONlatest 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

Note: In the followings examples, the _ between the { should be removed to make it work.

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.*

AUTHOR

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