Interpolate text quickly in ruby
You could store a format string:
my_string = "Congrats, you have joined %s"
group_name = "My Group"
puts my_string % group_name # prints: Congrats, you have joined My Group
For multiple variables in the same string you can use
my_string = "Congrats, you have joined %s and %s"
group_name = ['group1', 'group2']
puts my_string % ['group1', 'group2'] # prints: Congrats, you have joined group1 and group2
A nice to Interpolate text quickly in ruby.