Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_array.dart

Issue 12383073: Add List.insert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use insertBefore and add is-check. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_collection_dev/list.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/lib/js_array.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
index cbdacad46eaf946ecd0fc132b702d6362648cb4c..282fb78c7af17c93a6da08d8f2eeecb860ffd46f 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
@@ -27,6 +27,15 @@ class JSArray<E> implements List<E>, JSIndexable {
return JS('var', r'#.splice(#, 1)[0]', this, index);
}
+ void insert(int index, E value) {
+ if (index is !int) throw new ArgumentError(index);
+ if (index < 0 || index > length) {
+ throw new RangeError.value(index);
+ }
+ checkGrowable(this, 'insert');
+ JS('void', r'#.splice(#, 0, #)', this, index, value);
+ }
+
E removeLast() {
checkGrowable(this, 'removeLast');
if (length == 0) throw new RangeError.value(-1);
« no previous file with comments | « sdk/lib/_collection_dev/list.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698