Ruby chaining methods with if-statement -


this question has answer here:

i have following:

def method(integer)     = 3+integer   += 10 if "one"<"another" end 

can write in 1 line somehow chaining methods?

something a = 3+f += 10 if "one"<"another"?

since and or && both use short-circuit evaluation, use:

(a = 3+integer) , ("one"<"another") ,  (a += 10)  

it says in 'using “and” , “or” in ruby':

and useful chaining related operations until 1 of them returns nil or false

another way of thinking and reversed if statement modifier


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -