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
// data with a key
abstract class Data<K> {
K get key;
}
// link to some data
class Link<K, T extends Data<K>> {
Link({ T? value, K? key }) : _value = value, _key = key;
final K? _key;
final T? _value;
}
The Link class has two generics K and T but K could be inferred from T.
Would it be possible to simply write:
class Link<T extends Data<K>> {
Link({ T? value, K? key }) : _value = value, _key = key;
final K? _key;
final T? _value;
}
Currently, client classes look like:
// some data
class A implements Data<String> {
A(this.key);
final String key;
}
// some other data
class B implements Data<int> {
B(this.key);
final int key;
Link<String, A>? property;
}
The Link<String, A>? property is essentially a Link<A>. String is redundant and is actually forced by the use of A.
The text was updated successfully, but these errors were encountered:
Consider the following classes:
The Link class has two generics K and T but K could be inferred from T.
Would it be possible to simply write:
Currently, client classes look like:
The
Link<String, A>? property
is essentially aLink<A>
. String is redundant and is actually forced by the use of A.The text was updated successfully, but these errors were encountered: