Method: Kernel#with

Defined in:
lib/core/facets/kernel/with.rb

#with(obj = self, &block) ⇒ Object

Like returning but exectues the block via instance_eval.

def foo
  with values = [] do
    self << 'bar'
    self << 'baz'
  end
end

foo # => ['bar', 'baz']


15
16
17
# File 'lib/core/facets/kernel/with.rb', line 15

def with(obj=self, &block)
  obj.instance_eval(&block)
end