This repository was archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
IFS
Kirill Chernyshov edited this page Mar 13, 2019
·
1 revision
IFS returns the value that corresponds to the first logical expression which evaluates to TRUE.
IFS(cond1, expr1, ... , condN, exprN)
-
condNis a condition that evaluates to truthy of falsy value. -
exprNis an expression that is evaluated only when corresponding condition returns truthy value. Result is returned as a result ofIFSexpression.
-
IFSexpecting even number of arguments.
With given context:
{
"users": [
{
"name": "Hans",
"surname": "Petrov"
},
{
"name": "Ivan"
}
]
}Expression like that:
MAP(IFS(_.surname <> NULL, _.surname, _.surname = NULL, 'Unknown surname'), users)
will return a collection ["Petrov", "Unknown surname"].
In this example we are using MAP function to walk other a list of users fetched from the context and apply IFS to fetch surname attribute from each of them. In case when surname is not defined - return just placeholder.