Skip to content

Instantly share code, notes, and snippets.

@lazyatom
Forked from evanphx/gist:663383
Created November 4, 2010 23:39
Show Gist options
  • Save lazyatom/663407 to your computer and use it in GitHub Desktop.
Save lazyatom/663407 to your computer and use it in GitHub Desktop.
class BetterNews
def initialize(string, required)
@age = required
@string = string
end
attr_reader :age
def method_missing(name, *args)
self.class.new(@string.send(name, *args), @age)
end
end
b = BetterNews.new('hello', 10)
p b
c = b.gsub("l", "r")
p c
p c.class
p c.age
# ... but still not generally a good idea.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment