Chromium Code Reviews| Index: sdk/lib/collection/collections.dart |
| diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart |
| index fb9a94b8832dcbfb685b08ca6d39ab0750444a8e..6f0d42692527977a809ca31c6bda463266fcd7a6 100644 |
| --- a/sdk/lib/collection/collections.dart |
| +++ b/sdk/lib/collection/collections.dart |
| @@ -12,6 +12,18 @@ part of dart.collection; |
| */ |
| class UnmodifiableListView<E> extends UnmodifiableListBase<E> { |
| final Iterable<E> _source; |
| + |
| + /** |
| + * Returns a view of [source] that's guaranteed to be unmodifiable. |
| + * |
| + * If [source] already extends [UnmodifiableListBase] or |
| + * [UnmodifiableListView], this avoids re-wrapping it. |
|
Lasse Reichstein Nielsen
2015/08/27 07:59:04
-> , it is returned without re-wrapping it.
(to s
nweiz
2015/08/27 19:25:37
Done.
|
| + */ |
| + static List ensure(Iterable source) => |
|
Lasse Reichstein Nielsen
2015/08/27 07:59:04
I'm not sure I like the name. It's too ... non-des
Lasse Reichstein Nielsen
2015/08/27 07:59:04
Move static method below constructor.
nweiz
2015/08/27 19:25:37
My intention was that it would be clear that it wo
sra1
2015/08/27 20:24:52
How does this type-check in DDC?
nweiz
2015/08/28 00:41:29
I'm not sure how to test that... "dartanalyzer --s
Lasse Reichstein Nielsen
2015/08/31 09:08:23
UmodifiableListView.unmodifiable isn't very clear
Bob Nystrom
2015/08/31 20:42:45
Drive-by comment! A 39-character method name is pr
|
| + source is UnmodifiableListBase |
|
Lasse Reichstein Nielsen
2015/08/27 07:59:04
This is slightly dangerous because someone might h
sra1
2015/10/06 19:19:22
I don't think it is clear because it is not clear
|
| + ? source |
| + : new UnmodifiableListView(source); |
| + |
| /** Create an unmodifiable list backed by [source]. */ |
| UnmodifiableListView(Iterable<E> source) : _source = source; |
|
sra1
2015/10/06 19:19:22
Question: why is source Iterable?
Lasse Reichstein Nielsen
2015/10/07 07:40:40
Because the UnmodifiableListView is also a way to
|
| int get length => _source.length; |