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

Unified Diff: sdk/lib/core/string.dart

Issue 172153002: Add String.repeat, String.padLeft, String.padRight. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed multi-char padding from padLeft/Right. Created 6 years, 10 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/_internal/lib/js_string.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/string.dart
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index 799a2a96837e06652a54cb6cfb6b243d1ebea063..0a3c617d514986e5f2a039964385531983f5e88a 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -326,6 +326,44 @@ abstract class String implements Comparable<String>, Pattern {
String trim();
/**
+ * Creates a new string that repeats this string a number of times.
+ *
+ * If [separator] is provided, it is inserted between the copies
+ * of this string.
+ *
+ * The [times] number must be non-negative.
+ */
+ String repeat(int times, [String separator = ""]);
+
+ /**
+ * Pads this string on the left if it is shorther than [newSize].
+ *
+ * Return a new string that prepends [padding] onto this string
+ * until the total length is [newLength].
+ *
+ * If [newLength] is already smaller than or equal to `this.length`,
+ * no padding will happen. A negative `newLength` is allowed,
+ * but no padding happens.
+ *
+ * The [padding] must have length 1.
+ */
+ String padLeft(int newLength, String padding);
+
+ /**
+ * Pads this string on the right if it is shorther than [newSize].
+ *
+ * Return a new string that append [padding] after this string
+ * until the total length is [newLength].
+ *
+ * If [newLength] is already smaller than or equal to `this.length`,
+ * no padding will happen. A negative `newLength` is allowed,
+ * but no padding happens.
+ *
+ * The [padding] must have length 1.
+ */
+ String padRight(int newLength, String padding);
+
+ /**
* Returns true if this string contains a match of [other]:
*
* var string = 'Dart strings';
« no previous file with comments | « sdk/lib/_internal/lib/js_string.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698