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

Unified Diff: lib/src/utils.dart

Issue 1715523003: Warn when an unsupported platform is passed. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 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
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index da3f9af494b25bc1676edcf09b3a93cde0b66988..6d54faf0b1d8c284e8ddc1d0643123b58a40e954 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -103,12 +103,14 @@ String indent(String str) =>
/// Returns a sentence fragment listing the elements of [iter].
///
/// This converts each element of [iter] to a string and separates them with
-/// commas and/or "and" where appropriate.
-String toSentence(Iterable iter) {
+/// commas and/or [conjunction] where appropriate. The [conjunction] defaults to
+/// "and".
+String toSentence(Iterable iter, {String conjunction}) {
if (iter.length == 1) return iter.first.toString();
+
var result = iter.take(iter.length - 1).join(", ");
if (iter.length > 2) result += ",";
- return "$result and ${iter.last}";
+ return "$result ${conjunction ?? 'and'} ${iter.last}";
}
/// Returns [name] if [number] is 1, or the plural of [name] otherwise.
« lib/src/backend/operating_system.dart ('K') | « lib/src/runner.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698