Right now I have I feel like a very ugly way of setting a variable to a value depending on if it returns an empty string or not. Below is the method in question (it uses Nokogiri, but that doesn't really matter for this question).
def get_let(response)
if response.css('A').empty?
if response.css('B').empty?
let = ''
end
let = response.css('B')
else
let = response.css('A')
end
return let
end
def get_let(response)
let = response.css('A')
let = response.css('B') if let.empty?
let = '' if let.empty?
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With