-
Notifications
You must be signed in to change notification settings - Fork 214
Let types declare default values, and make them available on type variables. #1227
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
Comments
if T is a complex class, like: class Stud {
int age = 12;
String name = '';
Stud(int age) {
this.aget= age;
}
// not allow T? prop
default Stud(3); // and if T is Stud, then default(T) is Stud(3)
} |
The request is that a type can declare a "default value" ( Here it's requested that this works on a type variable. That's a very tricky request. If not all classes declare a We'd have to make it part of the type parameter constraint: I guess all nullable types will have |
About types like |
may be can support class Foo<T is! nullable> {} , then user can not use Foo<someType?> |
i can't think out what's the situation should use int?? type.. |
@Silentdoer this is already expressible via
It arises accidentally in some places, and is harmless. The type system treats it as equivalent to |
Uh oh!
There was an error while loading. Please reload this page.
please consider following code, and it's comment.
The text was updated successfully, but these errors were encountered: