Last active
February 26, 2016 02:16
-
-
Save libbyschuknight/32a49cfdb4e29913f2af to your computer and use it in GitHub Desktop.
how to re-write if/else with unless
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
json_error = JSON.parse(error.response.body)["error"] | |
if json_error == "error:price_not_found" | |
nil | |
else | |
raise error | |
end | |
# better like this, does same thing | |
json_error = JSON.parse(error.response.body)["error"] | |
raise error unless json_error == "error:price_not_found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment