How do I shorten a one line if statement in ruby that only executes if field is not empty -
i have following if
statement fills field result of function, if function doesn't return empty.
i think i've seen examples before empty check , function can combined in if
without me having repeat whole function again in condition.
i'm looking newb dry advice please!
icons = page.search("theicons").to_s if !page.search("theicons").to_s.empty?
is wrong with
theicons = page.search("theicons").to_s icons = theicons unless theicons.empty?
Comments
Post a Comment