Skip to content

Commit

Permalink
Add printAll() cos I always seem to need it
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Aug 13, 2013
1 parent b9342b8 commit 8f3d09c
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/ceylon/language/print.ceylon
@@ -1,15 +1,33 @@
"Print a line to the standard output of the virtual "Print a line to the standard output of the virtual machine
machine process, printing the given value\'s `string`, process, printing the given value\'s `string`, or `<null>`
or `\{#ab}null\{#bb}` if the value is `null`. if the value is `null`.
This method is a shortcut for: 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." and is intended mainly for debugging purposes."
// FIXME: see https://github.com/ceylon/ceylon-spec/issues/694 // FIXME: see https://github.com/ceylon/ceylon-spec/issues/694
//see (`process.writeLine`) //see (`process.writeLine`)
by ("Gavin") by ("Gavin")
shared void print(Anything line) { shared void print(Anything val) =>
process.writeLine(line?.string else "\{#ab}null\{#bb}"); 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>";

0 comments on commit 8f3d09c

Please sign in to comment.