Skip to content

Instantly share code, notes, and snippets.

@lightningdb
Created May 25, 2010 06:26
Show Gist options
  • Save lightningdb/412845 to your computer and use it in GitHub Desktop.
Save lightningdb/412845 to your computer and use it in GitHub Desktop.
# longer and harder to read, with redundant lines
facet_values_after = []
facet_values.each do | facet_value |
facet_value = facet_value.gsub(/\_/, '\-')
facet_values_after << facet_value.gsub(/"/, '\"')
end
return facet_values_after
# can be turned into
facet_values.collect do |value|
# escape special values
value.gsub(/\_/, '\-').gsub(/"/, '\"')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment