Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

QL add expression for alternative default value #5348

Marcono1234 started this conversation in Ideas
Discussion options

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() | ...).

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /