Skip to content

Instantly share code, notes, and snippets.

@dmgarland
Created September 22, 2011 10:13
Show Gist options
  • Save dmgarland/1234471 to your computer and use it in GitHub Desktop.
Save dmgarland/1234471 to your computer and use it in GitHub Desktop.
irb(main):001:0> a = ["hello", "there"]
=> ["hello", "there"]
irb(main):002:0> a.map { |w| w.include?[^Chere"]}
irb(main):002:0> a
=> ["hello", "there"]
irb(main):003:0> b = ["there"]
=> ["there"]
irb(main):004:0> a.map { |w| b.include?(w) ? "<b>#{w}</b>" : w }
=> ["hello", "<b>there</b>"]
irb(main):005:0> a
=> ["hello", "there"]
irb(main):006:0> a.map! { |w| b.include?(w) ? "<b>#{w}</b>" : w }
=> ["hello", "<b>there</b>"]
irb(main):007:0> a
=> ["hello", "<b>there</b>"]
irb(main):008:0> a.join " "
=> "hello <b>there</b>"
irb(main):009:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment