Order disjoint list items: Difference between revisions

m
m (→‎sprintf version: Add comment)
Line 2,176:
nn = n.split
nn.each {|item| mm.sub!(item, "%s")} #sub! only subs the first match
mm % nn #"the %s sat on the %s" % [mat", "cat"] #does what you hope it does.
mm % nn
end
 
1,149

edits