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

Unified Diff: runtime/lib/string_patch.dart

Issue 17281002: Make String.startsWith take an optional start index. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 7 years, 6 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 | « no previous file | sdk/lib/_internal/lib/js_string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string_patch.dart
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index 80b369cb10003122b2307fe367cc762914e68254..2d40f2de1eff3fafe8d2d639562cfac914098f0d 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -129,11 +129,14 @@ class _StringBase {
return _substringMatches(this.length - other.length, other);
}
- bool startsWith(Pattern pattern) {
+ bool startsWith(Pattern pattern, [int index = 0]) {
+ if (index < 0 || index > this.length) {
+ throw new RangeError.range(index, 0, this.length);
+ }
if (pattern is String) {
- return _substringMatches(0, pattern);
+ return _substringMatches(index, pattern);
}
- return pattern.matchAsPrefix(this, 0) != null;
+ return pattern.matchAsPrefix(this, index) != null;
}
int indexOf(Pattern pattern, [int start = 0]) {
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698