abstract class Collection<E> { Collection<E> newInstance(); Collection<E> map((f) { var result = newInstance(); forEach((E e) { result.add(f(e)); }); return result; } } abstract class DOMElementList<E> = DOMList with Collection<E>; abstract class DOMElementSet<E> = DOMSet with Collection<E>; // ... 28 more variants
Hi,
the article Mixins in Dart shows the following example:
abstract class Collection<E> { Collection<E> newInstance(); Collection<E> map((f) { var result = newInstance(); forEach((E e) { result.add(f(e)); }); return result; } } abstract class DOMElementList<E> = DOMList with Collection<E>; abstract class DOMElementSet<E> = DOMSet with Collection<E>; // ... 28 more variants
I don't understand where forEach comes from. Shouldn't it be a method of Collection<E>?
BTW, it seems there's one parenthesis too many on the third line.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Hi,
the article Mixins in Dart shows the following example:
abstract class Collection<E> { Collection<E> newInstance(); Collection<E> map((f) { var result = newInstance(); forEach((E e) { result.add(f(e)); }); return result; } } abstract class DOMElementList<E> = DOMList with Collection<E>; abstract class DOMElementSet<E> = DOMSet with Collection<E>; // ... 28 more variants
I don't understand where forEach comes from. Shouldn't it be a method of Collection<E>?
BTW, it seems there's one parenthesis too many on the third line.