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
I have to wrap constructors in factory methods in order to use them in higher-ordrer functions. I expect that in a context where a function is required that has the same signature as the constructor, a type name should be interpreted as the constructor.
Code
/// A [map] function that takes in 2 iterables.Iterable<V> _map2<T, U, V>(
Iterable<T> ts, Iterable<U> us, VFunction(T t, U u) func) sync* {
finalIterator<T> itt = ts.iterator;
finalIterator<U> itu = us.iterator;
bool uMoveNext = itu.moveNext();
bool tMoveNext = itt.moveNext();
while (uMoveNext && tMoveNext) {
yieldfunc(itt.current, itu.current);
uMoveNext = itu.moveNext();
tMoveNext = itt.moveNext();
}
if (itu.moveNext() || itt.moveNext()) {
throwException('Arguments to _map2 aren\'t the same length.');
}
}
class_Tuple<T, U> {
_Tuple(this.first, this.second);
static_Tuple<T, U> make<T, U>(T t, U u) =>_Tuple<T, U>(t, u);
T first;
U second;
}
// WORKAROUNDIterable<_Tuple<T, U>> _zip<T, U>(Iterable<T> ts, Iterable<U> us) =>_map2(ts, us, _Tuple.make);
// DOESN'T WORKIterable<_Tuple<T, U>> _zip<T, U>(Iterable<T> ts, Iterable<U> us) =>_map2(ts, us, _Tuple);
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Description
I have to wrap constructors in factory methods in order to use them in higher-ordrer functions. I expect that in a context where a function is required that has the same signature as the constructor, a type name should be interpreted as the constructor.
Code
The text was updated successfully, but these errors were encountered: