Lars Christensen
1/4/2008 12:01:00 PM
On Jan 4, 11:51 am, ole __ <oliver.saund...@gmail.com> wrote:
> I'm pretty sure ruby doesn't have a with statement. Is it possible to
> emulate one?
Yes:
module Kernel
def with(obj, &b)
obj.instance_eval(&b)
end
end
Usage:
class Foo
def dostuff
puts "doing stuff in Foo"
end
end
foo = Foo.new
with foo do
dostuff
end
Rgds,
Lars