Closed ashmaroli closed 3 years ago
String#gsub also accepts a Hash to replace matches in a single go. Code such as the following can be optimized with a constant:
String#gsub
def process_escapes(str) str. gsub('\\\\', '\'). gsub('\"', '"'). gsub("\\\'", '''). gsub('\.', '.'). gsub('\-', '-'). gsub('\`', '`') end
String#gsub
also accepts a Hash to replace matches in a single go. Code such as the following can be optimized with a constant: