You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Optional error type with defaultsealedclassResult<T, [EextendsException]> {...}
// `E` defaults to `Exception`Result<User> getUser() {...}
// Custom error typeResult<User, ApiError> getUser2() {...}
Similar to our current examples of optional positional parameters, we could have an optional type parameter.
This would make code bases with strict_raw_type: true have maybe less work when the extended type is always the expected type (if we agree that for example it could have a lint similar to avoid_redundant_argument_values).
The text was updated successfully, but these errors were encountered:
I'm the author of the post, honestly I'm not sure if it's a good idea or worth the effort.
But following the same idea, we can imagine named generics which would allow arbitrary parameter ordering and optional types as well.
classMyClass<{A, BextendsObject, Cextendsnum = int}> {}
final v =MyClass<A: SomeType1, B: SomeType2, C: double>();
final v2 =MyClass<B: SomeType2, A: SomeType1>(); // c default to int, params use arbitrary order
I saw this post on X.
The post has this code example:
Similar to our current examples of optional positional parameters, we could have an optional type parameter.
This would make code bases with
strict_raw_type: true
have maybe less work when the extended type is always the expected type (if we agree that for example it could have a lint similar to avoid_redundant_argument_values).The text was updated successfully, but these errors were encountered: