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

Unified Diff: runtime/lib/array.dart

Issue 8424012: Add optional arguments to our indexOf/lastIndexOf methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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
Index: runtime/lib/array.dart
===================================================================
--- runtime/lib/array.dart (revision 942)
+++ runtime/lib/array.dart (working copy)
@@ -116,12 +116,13 @@
DualPivotQuicksort.sort(this, compare);
}
- int indexOf(T element, int startIndex) {
- return Arrays.indexOf(this, element, startIndex, this.length);
+ int indexOf(T element, [int start = 0]) {
+ return Arrays.indexOf(this, element, start, this.length);
}
- int lastIndexOf(T element, int startIndex) {
- return Arrays.lastIndexOf(this, element, startIndex);
+ int lastIndexOf(T element, [int start = null]) {
+ if (start === null) start = length - 1;
+ return Arrays.lastIndexOf(this, element, start);
}
Iterator<T> iterator() {
@@ -243,12 +244,13 @@
return "ImmutableArray";
}
- int indexOf(T element, int startIndex) {
- return Arrays.indexOf(this, element, startIndex, this.length);
+ int indexOf(T element, [int start = 0]) {
+ return Arrays.indexOf(this, element, start, this.length);
}
- int lastIndexOf(T element, int startIndex) {
- return Arrays.lastIndexOf(this, element, startIndex);
+ int lastIndexOf(T element, [int start = null]) {
+ if (start === null) start = length - 1;
+ return Arrays.lastIndexOf(this, element, start);
}
Iterator<T> iterator() {

Powered by Google App Engine
This is Rietveld 408576698