-
Notifications
You must be signed in to change notification settings - Fork 1.9k
QL add expression for alternative default value #5348
Marcono1234
started this conversation in
Ideas
-
Now and then there are cases where an expression might not have a result and a default value is chosen instead. Such code typically looks like this
if exists(getSomething()) then value = getSomething() else value = "default"
(please let me know if there is a better alternative)
This is error-prone because you have to write the expression which yields the result twice. Would it be possible to introduce a built-in defaults(... | ...) expression (or similar) which simplifies this? E.g.:
value = defaults(getSomething() | "default")
It might also be useful to support an arbitrary number of alternative default values, each as fallback for the previous one, e.g. defaults(first() | second() | third() | ...).
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment