String interpolation with actual % in string
ruby, string-formatting
Solution
Two %'s
>> "Hi %s, today is %s so you get 10%% OFF!" % ['Joe', 'Monday']
=> "Hi Joe, today is Monday so you get 10% OFF!"
Problem
What's the right way to deal with this? ``` "Hi %s, today is %s so you get 10% OFF!" % ['Joe', 'Monday'] # => ArgumentError: malformed format string - %O ``` I can't use normal `%{keyname}` or `#{code}` because I'm parsing strings for urls and stripping them out so I can stick them back in different formats (with/without protocol, shortened, full length, etc). So the number of replacements is unknown and they don't have names. They are just an array of urls. I also tried escaping the `%`: ``` "Hi %s, today is %s so you get 10\% OFF!" % ['Joe', 'Monday'] # => ArgumentError: malformed format string - %O ``` but get the exact same result.