Created
May 30, 2014 02:24
-
-
Save aharpole/736c5dd4a3a62b293a94 to your computer and use it in GitHub Desktop.
safe use of rescue nil
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
def chunky_peanut_butter | |
EndlessChunkyPBSupplier.grab(:chunky_pb) | |
end | |
def smooth_peanut_butter | |
Cabinet.fetch(:smooth_peanut_butter) rescue nil | |
end | |
def make_pb_and_j | |
pb = smooth_peanut_butter || chunky_peanut_butter | |
... | |
end | |
def make_peanut_butter_fudge | |
pb = smooth_peanut_butter || raise "Only smooth peanut butter will do" | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment