Optional parameters: Difference between revisions
m
→{{header|Ecstasy}}
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag) |
|||
Line 875:
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module OptionalParameters {
typedef Type<String >.Orderer as ColumnOrderer;
typedef Type<String[]>.Orderer as RowOrderer;
Line 884 ⟶ 883:
Int column = 0,
Boolean reverse = False,
) {
// provide a default orderer
orderer ?:= (s1, s2) -> s1 <=> s2;
Line 898 ⟶ 896:
return table.sorted(byColumn);
void run() {
String[][] table =
[
Line 913 ⟶ 910:
show("by column 2", sort(table, column=2));
show("by column 2 reversed", sort(table, column=2, reverse=True));
void show(String title, String[][] table) {
@Inject Console console;
console.print($"{title}:");
for (val row : table) {
console.print($" {row}");
console.print();▼
}
▲ console.print();
}
}
</syntaxhighlight>
|