I have the following code which seems verbose for what I want it to do:
if @initial_that.present?
@that = @initial_that
get_talk_api_response
else
get_talk_api_response
end
It looks like I could make it DRY, but not sure how.
i'm sure there's a computer science name for this refactor, but you're calling get_talk_api_response in both branches, so put it outside the conditional instead:
if @initial_that.present?
@that = @initial_that
end
get_talk_api_response
and then to make it look more ruby-like, per the hot comment:
@that = @initial_that if @initial_that.present?
get_talk_api_response
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments