Mega Code Archive

 
Categories / Ruby / String
 

Change the output on the fly with the %s format flag and %

hi = "Hello, %s" puts hi % "Tom!" # => "Hello, Tom!" puts hi % "people!" # => "Hello, people!" puts hi % "universe!" # => "Hello, universe!"