Skip to content

Instantly share code, notes, and snippets.

@jbarnette
Forked from bmizerany/gist:760583
Created December 31, 2010 01:30
Show Gist options
  • Save jbarnette/760597 to your computer and use it in GitHub Desktop.
Save jbarnette/760597 to your computer and use it in GitHub Desktop.
# 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
@rkh
Copy link

rkh commented Apr 1, 2011

if you dont care about the exception class, you can also do a def on(error, message = yield).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment