Skip to content

Instantly share code, notes, and snippets.

@libbyschuknight
Last active February 26, 2016 02:16
Show Gist options
  • Save libbyschuknight/32a49cfdb4e29913f2af to your computer and use it in GitHub Desktop.
Save libbyschuknight/32a49cfdb4e29913f2af to your computer and use it in GitHub Desktop.
how to re-write if/else with unless
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