def extract_values(arr)
      values = []
      mapped = arr.map do |e|
        next e.gsub('{', '{{') if e.is_a?(String)
        values << e
        next "{#{values.count - 1}}"
      end
      return mapped.join, values
    end
def extract_values(arr)
      values = []
      mapped = arr.map do |e|
        next e.gsub('{', '{{') if e.is_a?(String)
        values << e
        next "{#{values.count - 1}}"
      end
      return mapped.join, values
    end
Extracts the non-string vlaues from an array containing both strings and non-strings.
 These values are replaced with escape sequences.
 This can be undone using \{#inject\_values}.

 This is useful e.g. when we want to do string manipulation
 on an interpolated string.

 The precise format of the resulting string is not guaranteed.
 However, it is guaranteed that newlines and whitespace won't be affected.

 @param arr [Array] The array from which values are extracted.
 @return [(String, Array)] The resulting string, and an array of extracted values.