Skip to content

Instantly share code, notes, and snippets.

@fronx
Forked from addywaddy/gist:222349
Created October 30, 2009 14:12
Show Gist options
  • Save fronx/222357 to your computer and use it in GitHub Desktop.
Save fronx/222357 to your computer and use it in GitHub Desktop.
class String
@@all = []
def /(other)
@@all << "#{self} #{other}"
@@all.join(' and ')
end
def self.reset
@@all = []
end
end
def print_these_strings
result = yield
String.reset
puts result
end
print_these_strings do
"hello" / "bob"
"goodbye" / "joe"
end
#
# => "hello bob and goodbye joe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment