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

Unified Diff: runtime/lib/string.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/string.dart
===================================================================
--- runtime/lib/string.dart (revision 942)
+++ runtime/lib/string.dart (working copy)
@@ -103,7 +103,7 @@
return this.substringMatches(0, other);
}
- int indexOf(String other, int startIndex) {
+ int indexOf(String other, [int startIndex = 0]) {
if (other.isEmpty()) {
return startIndex < this.length ? startIndex : this.length;
}
@@ -119,7 +119,8 @@
return -1;
}
- int lastIndexOf(String other, int fromIndex) {
+ int lastIndexOf(String other, [int fromIndex = null]) {
+ if (fromIndex == null) fromIndex = length - 1;
if (other.isEmpty()) {
return Math.min(this.length, fromIndex);
}

Powered by Google App Engine
This is Rietveld 408576698