David - Musings of an SRE

Format strings dynamically in ruby

#TIL you can format strings dynamically and neatly with:

puts "%s is at %s" % [
  'John',
  'Singapore'
]

=> John is at Singapore

2021 Update

The above is similar to how we do it in go

person := "John"
country := "Singapore"
fmt.Printf("%s is at %s", person, country)

References: