Created
January 28, 2011 10:04
-
-
Save seban/800061 to your computer and use it in GitHub Desktop.
Mala zagadka programistyczna #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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