Skip to content

Instantly share code, notes, and snippets.

@seban
Created January 28, 2011 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seban/800061 to your computer and use it in GitHub Desktop.
Save seban/800061 to your computer and use it in GitHub Desktop.
Mala zagadka programistyczna #1
# Ruby
def exception_return_puzzle?
begin
return true
ensure
return false
end
end
# Java
boolean is_exception_return_puzzle() {
try {
return true;
} finally {
return false;
}
}
# PHP
function exception_return_puzzle() {
try {
return true;
} finally {
return false;
}
}
# Clojure
(defn is_exception_return_puzzle[]
(try
true
(finally
(println "FOO")
false)))
# Python
def exception_return_puzzle():
try:
return True
finally:
return False
# JavaScript
function is_exception_return_puzzle() {
try {
return true;
} finally {
return false;
}
}
# Scala
def is_exception_puzzle: Boolean =
try {
return true
} finally {
return false
}
# Erlang
is_exception_return_puzzle() ->
try
true
after
io:fwrite("after\n"),
false
end.
# ActionScript
private function is_exception_return_puzzle():Boolean {
try {
return true;
} finally {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment