Skip to content

Simplified syntax for null-coalescing operator #1406

@luis-j-soares

Description

@luis-j-soares

I was showcasing ternary and null-coalescing operators in a workshop today, and this question came up: "why is ternary turning simple expressions into if/else statements, but null-coalescing doesn't?"

So we could take #1341 and extend it to null-coalescing expressions.

chosenUser = user ?? {}

' transpiles to...

chosenUser = bslib_coalesce(user, {})

' but it could transpile to...

chosenUser = user
if chosenUser = invalid
    chosenUser = {}
end if

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions