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

Optional Chaining Operator #328

Closed
Clashsoft opened this issue Feb 13, 2017 · 0 comments
Closed

Optional Chaining Operator #328

Clashsoft opened this issue Feb 13, 2017 · 0 comments
Assignees
Labels
epic:Syntax Changes to the syntax of the language module:Compiler Implementation requires major changes to the compiler type:Feature New functionality
Milestone

Comments

@Clashsoft
Copy link
Member

Clashsoft commented Feb 13, 2017

Add a new operator that allows safe optional chaining.

Example:

let opt: String? = "test"

let upper = opt.toUpperCase // error
let upper = opt == null ? null : opt!!.toUpperCase // verbose

let upper: String? = opt?.toUpperCase // optional access

let firstUpper: char? = opt?.toUpperCase?[0] // multiple optional accesses can be chained
@Clashsoft Clashsoft self-assigned this Feb 13, 2017
@Clashsoft Clashsoft added module:Compiler Implementation requires major changes to the compiler type:Feature New functionality epic:Syntax Changes to the syntax of the language labels Feb 13, 2017
@Clashsoft Clashsoft added the status:Upcoming Implemented and scheduled for the next release label Mar 5, 2017
@Clashsoft Clashsoft added this to the v0.30.0 milestone Mar 5, 2017
Clashsoft added a commit that referenced this issue Mar 10, 2017
lang: Added support for the Optional Chaining operators `?.` and `??`.
#328
comp: Added AST nodes for Optional Chain `?.` and Null Coalescing `??`
operators. #328
lib: Updated the `Optionals` class.
dpf: Updated some classes to make use of Optional Chaining.
(test): Actived the `OptionalTest`.
@Clashsoft Clashsoft removed the status:Upcoming Implemented and scheduled for the next release label Mar 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic:Syntax Changes to the syntax of the language module:Compiler Implementation requires major changes to the compiler type:Feature New functionality
Projects
None yet
Development

No branches or pull requests

1 participant