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

Conditional (ternary) expression #94

Closed
mhbdev opened this issue Nov 28, 2023 · 2 comments · Fixed by #97
Closed

Conditional (ternary) expression #94

mhbdev opened this issue Nov 28, 2023 · 2 comments · Fixed by #97

Comments

@mhbdev
Copy link

mhbdev commented Nov 28, 2023

It would be nice if we have something like ternary operator in javascript or any other languages. It would help us with less code and easier implementation of simple null checks and if statements.

@anton-trunov anton-trunov changed the title [FEATURE] - Conditional (ternary) operator Conditional (ternary) expression Nov 28, 2023
@anton-trunov
Copy link
Member

Thanks for the feature request. Btw, the if-expression feature makes feature request #93 redundant:

let test: Int = if (condition0) 0 else 1;

@mhbdev
Copy link
Author

mhbdev commented Nov 28, 2023

Thanks for the feature request. Btw, the if-expression feature makes feature request #93 redundant:

let test: Int = if (condition0) 0 else 1;

That's right. Also, Adding something like ?? for null checks would be great.

let a: Int? = null;
let b: Int = a ?? 0;
dump(b);

// Output: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants