Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(defn f [& [x]]
(if (integer? x)
(println "Present" x)
(println "Not present")))
(defn f
([] (println "Not present"))
([x] (println "Present" x)))
void f({int? x}) => print(x == null ? "Not present" : "Present");
subroutine f(x)
integer, optional :: x
if (present(x)) then
print *,"Present", x
else
print *,"Not present"
end if
end subroutine f
func f(x ...int) {
if len(x) > 0 {
println("Present", x[0])
} else {
println("Not present")
}
}
function f(x) {
console.log(x ? `Present: ${x}` : 'Not present');
}
private void f(Integer x) {
if (x != null) {
System.out.println("Present " + x);
} else {
System.out.println("Not present");
}
}
function f( x )
if x then
print("Present", x)
else
print("Not present")
end
end
function f(?int $x = null) {
echo $x ? 'Present' . $x : 'Not present';
}
procedure f; overload;
begin
writeln('not present');
end;
procedure f(x: integer); overload;
begin
writeln('present');
end;
sub f {
my $x = shift;
if (defined $x) {
print("Present $x\n");
}
else {
print("Not Present\n");
}
}
def f(x=None):
if x is None:
print("Not present")
else:
print("Present", x)
def f( x=nil )
puts x ? "present" : "not present"
end
fn f(x: Option<()>) {
match x {
Some(x) => println!("Present {}", x),
None => println!("Not present"),
}
}