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 ifwithout 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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -