I have 4 string variables name, quest, favorite_color, speed that might be empty. I want to concatenate them all together, putting spaces between those that aren\'
name, quest, favorite_color, speed
You can use inject:
[name,quest,favorite_color,speed].inject("") {|k,v| v.empty? ? k : k << " " << v }.strip