What the Format?

1 · Jan Lelis · May 18, 2016, midnight
%a %A %b %B %c %d %e %E %f %g %G %i %o %p %s %u %x %X %% 0 $ # + - * space Ruby comes with a structured alternative to classic string interpolation: This episode will explore format strings, also known as the sprintf syntax. Recall the normal way of interpolating variables into a string: v = 42 "--> #{v} <--" # => "--> 42 <--" Format strings are different in that they use a string template and bind it to data via the % method:¹ v = 42 "--> %s <--" % v # => "--> 42 <--" This might look familia...