Skip to content

Feature: if let expression #6

@shortercode

Description

@shortercode

Description

Swift offers the if let statement, which allows the definition of an conditional statement that is executed if an optional parameter is not null. In addition it unwraps the optional value to its interior value and assigns it to a variable. With the exception of planned switch expressions Radiance doesn't have an alternative way to unwrap an Optional monad into its value, which would make this a valuable convenience to the language.

The swift syntax is:
if let VAR_NAME = EXPRESSION { STATEMENTS* }
It only works with the inbuilt Optional enum. Whereas the Rust syntax is:
if let ENUM_VARIANT ( VAR_NAME ) = EXPRESSION { STATEMENTS* }
Which allows for usage with any enum variant, with the slight downside of additional complexity.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions