-
-
Save jbarnette/760597 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# When anything, including nil, is a valid param and you need | |
# a clear way to know if a param was set or not. | |
def foo a, b = (b_was_not_passed = true; nil) | |
result = [a] | |
result << b unless b_was_not_passed | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you dont care about the exception class, you can also do a
def on(error, message = yield)
.