Gistlib Logo

gistlib

other ruby categories

short-circuiting code snippets in ruby

fix but keep short and use ternaries: `def convert(n) r = '' n%3 == 0 ? r << 'pling' : n%5 == 0 ? r << 'plang' : n%7 == 0 ? r << 'plong' : r.empty? ? n.to_s : r end` in ruby

gistlibby LogSnag