Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary operators for the remap syntax #3837

Closed
binarylogic opened this issue Sep 12, 2020 · 1 comment
Closed

Ternary operators for the remap syntax #3837

binarylogic opened this issue Sep 12, 2020 · 1 comment
Assignees
Labels
domain: vrl Anything related to the Vector Remap Language type: feature A value-adding code addition that introduce new functionality.

Comments

@binarylogic
Copy link
Contributor

binarylogic commented Sep 12, 2020

I am proposing that we support ternary operators for the remap syntax. This will help with inline assignment as well as the upcoming support for template strings (#3836).

Example

.level = .status >= 500 ? "error" : "info"

or this, which might already be done:

.level = if (.status >= 500) { "error" } else { "info" }

If the second example is done, let's close this.

@binarylogic binarylogic added type: feature A value-adding code addition that introduce new functionality. domain: vrl Anything related to the Vector Remap Language labels Sep 12, 2020
@binarylogic binarylogic added this to the 2020-09-14 - The Grid milestone Sep 17, 2020
@jamtur01 jamtur01 removed this from the 2020-09-28 - Derezzed milestone Oct 14, 2020
@JeanMertz JeanMertz added this to the 2020-10-26: Recognizer milestone Nov 9, 2020
@JeanMertz JeanMertz self-assigned this Nov 9, 2020
@JeanMertz
Copy link
Contributor

Remap is now an expression-based language. The if-statement returns the last expression of whatever arm matches (if/else if/else).

I'll close this as the second example now works:

.level = if .status >= 500 { "error" } else { "info" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: vrl Anything related to the Vector Remap Language type: feature A value-adding code addition that introduce new functionality.
Projects
None yet
Development

No branches or pull requests

4 participants