Optional parameters: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by 2 users not shown)
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>
 
Line 2,977 ⟶ 2,972:
sorter(the_data,"numeric");</syntaxhighlight>
 
=={{header|UnixUNIX Shell}}==
{{works with|bash|4.2}}
<syntaxhighlight lang="bash">#!/usr/bin/env bash
Line 3,143 ⟶ 3,138:
{{libheader|Wren-seq}}
Wren doesn't support optional parameters as such but does support method overloading by ''arity'' (i.e. number of parameters) which makes it easy to simulate them.
<syntaxhighlight lang="ecmascriptwren">import "./sort" for Cmp, Sort
import "./seq" for Lst
 
9,485

edits