# bad email_with_name = user.name + ' ' # good email_with_name = "#{user.name} " # better email_with_name = "%s " % [user.name, user.email]
Why is the latter better? It seems equally good, but less idiomatic and certainly less obvious to most Ruby programmers.
email_with_name = "%s " % [user.name, user.email]
can be easily identified even when many fields are added.On the contrary, strings like
email_with_name = "#{user.name} "
become quite cramped as soon as you use three or more fields.