Explain like I'm LITERALLY five…what does it mean to "format" a string? [closed]

The most common use of the phrase refers to the replacing of variable placeholders within a string with the correct string representations of the variables’ contents.

Consider:

temp_reading = 25.67528
puts "It is currently %0.1f degrees" % [temp_reading]

-> It is currently 25.7 degrees

String formatting is what turns the template into the string you see in the output.

Leave a Comment