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

Unified Diff: compiler/lib/implementation/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: compiler/lib/implementation/string.dart
===================================================================
--- compiler/lib/implementation/string.dart (revision 942)
+++ compiler/lib/implementation/string.dart (working copy)
@@ -47,9 +47,18 @@
return substringMatches(0, other);
}
- int indexOf(String other, int startIndex) native;
- int lastIndexOf(String other, int fromIndex) native;
+ int indexOf(String other, [int start = 0]) {
+ return _nativeIndexOf(other, start);
+ }
+ int lastIndexOf(String other, [int start = null]) {
+ if (start === null) start = length - 1;
+ return _nativeLastIndexOf(other, start);
+ }
+
+ int _nativeIndexOf(String other, int start) native;
+ int _nativeLastIndexOf(String other, int start) native;
+
bool isEmpty() {
return length == 0;
}
@@ -77,8 +86,7 @@
String trim() native;
- bool contains(Pattern pattern, int startIndex) {
- if (startIndex == null) startIndex = 0;
+ bool contains(Pattern pattern, [int startIndex = 0]) {
if (startIndex < 0 || startIndex > length) {
throw new IndexOutOfRangeException(startIndex);
}

Powered by Google App Engine
This is Rietveld 408576698