dart-lang / dart-lang/language

In type conversion, Dart lacks "as?" and "as!"

Open
#1,265 8 comments 2 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Just like Swift, it is very convenient under type conversion.
Compared with Swift, Dart's "as" is completely insufficient.

Now I urgently need "as?" and "as!" syntax support, because it can save me a lot of time and more possibilities. We no longer need to worry about a type conversion.

if (foo as? SliverBar) // then foo is promoted type SliverBar or null if not,And will not throw an error
foo may be "null" or any type.

Contributor guide

Open the contributing guide

Research direction

No source file, test, or entry point is named. Start by reviewing the proposed Dart syntax and its comparison with Swift, then determine the required type-promotion and null/error semantics. Done means the language specification defines the feature and its behavior consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, swift
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.