Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add printAll() cos I always seem to need it

  • Loading branch information...
commit 8f3d09c5cd48a7592915a2d2440a409960cc87dc 1 parent b9342b8
@gavinking gavinking authored
Showing with 24 additions and 6 deletions.
  1. +24 −6 src/ceylon/language/print.ceylon
View
30 src/ceylon/language/print.ceylon
@@ -1,15 +1,33 @@
-"Print a line to the standard output of the virtual
- machine process, printing the given value\'s `string`,
- or `\{#ab}null\{#bb}` if the value is `null`.
+"Print a line to the standard output of the virtual machine
+ process, printing the given value\'s `string`, or `<null>`
+ if the value is `null`.
This method is a shortcut for:
- process.writeLine(line?.string else \"\{#ab}null\{#bb}\")
+ process.writeLine(line?.string else \"<null>\")
and is intended mainly for debugging purposes."
// FIXME: see https://github.com/ceylon/ceylon-spec/issues/694
//see (`process.writeLine`)
by ("Gavin")
-shared void print(Anything line) {
- process.writeLine(line?.string else "\{#ab}null\{#bb}");
+shared void print(Anything val) =>
+ process.writeLine(stringify(val));
+
+"Print multiple values to the standard output of the virtual
+ machine process as a single line of text, separated by a
+ given character sequence."
+by ("Gavin")
+shared void printAll({Anything*} values,
+ "A character sequence to use to separate the values"
+ String separator=", ") {
+ if (exists first = values.first) {
+ process.write(stringify(first));
+ for (val in values.rest) {
+ process.write(separator);
+ process.write(stringify(val));
+ }
+ }
+ process.write(process.newline);
}
+
+String stringify(Anything val) => val?.string else "<null>";
Please sign in to comment.
Something went wrong with that request. Please try again.