Add "last" setter to List.
This allows assigning directly as `list.last = value` instead of
having to use the longer `list[list.length - 1] = value`.
It's just an abbreviation, like `list.last` is for reading.
If you use a List as a stack (which is a perfectly good use of it),
modifying the last element like this is a natural operation.
R=sgjesse@google.com
Review URL: https://codereview.chromium.org//315173005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/collection@37255 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/wrappers.dart b/lib/wrappers.dart
index 2034174..7723d58 100644
--- a/lib/wrappers.dart
+++ b/lib/wrappers.dart
@@ -124,6 +124,10 @@
_listBase[index] = value;
}
+ void set last(E value) {
+ _listBase.last = value;
+ }
+
void add(E value) {
_listBase.add(value);
}
@@ -427,7 +431,7 @@
/**
* Creates a modifiable [Set] view of the values of a [Map].
- *
+ *
* The `Set` view assumes that the keys of the `Map` can be uniquely determined
* from the values. The `keyForValue` function passed to the constructor finds
* the key for a single value. The `keyForValue` function should be consistent
diff --git a/pubspec.yaml b/pubspec.yaml
index 80b0972..0ae4b42 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: collection
-version: 0.9.3+1
+version: 1.0.0-dev
author: Dart Team <misc@dartlang.org>
description: Collections and utilities functions and classes related to collections.
homepage: http://www.dartlang.org
diff --git a/test/wrapper_test.dart b/test/wrapper_test.dart
index 5858aaf..414c8f7 100644
--- a/test/wrapper_test.dart
+++ b/test/wrapper_test.dart
@@ -197,6 +197,7 @@
expect.indexOf(val, 4).equals.indexOf(val, 4);
expect.insert(4, val).equals.insert(4, val);
expect.insertAll(4, [val]).equals.insertAll(4, [val]);
+ (expect..last = 5).equals.last = 5;
expect.lastIndexOf(val, null).equals.lastIndexOf(val);
expect.lastIndexOf(val, 4).equals.lastIndexOf(val, 4);
(expect..length = 4).equals.length = 4;