Type promotion for non-local variables using the is operator #2397
Labels
feature
Proposed language feature that solves one or more problems
state-duplicate
This issue or pull request already exists
The
is
operator in dart can check whether an instance is a type of another type.When using local variables of the type
Object
there is automatic type promotion, but when the instance of the object is anything else there is no promotion and the use of theas
operator is needed to cast.Other languages like C# support casting inside the
is
operator.https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/patterns#declaration-and-type-patterns
A feature like this would simplify the code and removes unnecessary lines that don't add anything but clutter.
An example implemenation
The text was updated successfully, but these errors were encountered: