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 foo [x]
(println (if (string? x) x "Nothing.")))
(foo "Hello, world!")
(foo 42)
foo(x) => print(x is String ? x : 'Nothing.');
foo('Hello, world!');
foo(42);
program main
call foo("Hello, world!")
call foo(42)
contains
subroutine foo(x)
class(*), intent(in) :: x
select type(x)
type is (character(len=*))
write (*,'(A)') x
class default
write (*,'(A)') "Nothing."
end select
end subroutine foo
end program main
function foo(x) {
console.log(typeof x == 'string' ? x : 'Nothing.')
}
foo('Hello, world!')
foo(42)
public static void main(String[] args) {
foo("Hello, world!");
foo(42);
}
private static void foo(Object x) {
if (x instanceof String) {
System.out.println(x);
} else {
System.out.println("Nothing.");
}
}
def foo(x):
if isinstance(x, str):
print(x)
else:
print('Nothing.')
return
foo('Hello, world!')
foo(42)
def foo(x)
puts x.class == String ? x : "Nothing"
end
foo("Hello, world")
foo(42)
(define (foo x)
(displayln
(if (string? x)
x
"Nothing")))
(foo "Hello, world!")
(foo 42)