------art_268_26888015.1321237829355
Content-Type: multipart/alternative; 
	boundary---art_269_21242482.1321237829356"

------art_269_21242482.1321237829356
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Binding#with

    def with(_local_variables)
      eval("Proc.new{ |#{_local_variables.keys.join(',')}| binding 
}").call(*_local_variables.values)
    end

Try it:

    b  inding.with(:a)
    b.eval('a')  #1

Now, it there a way to add a "yield" to the binding? I tried:

  def with(_local_variables, &_yields)
    eval("lambda{ |#{_local_variables.keys.join(',')},&yields| binding 
}").call(*_local_variables.values, &_yields)
  end

    b  inding.with{ |x| x+x}
    b.eval('yields[1]')  #2

but

    b.eval('yield(1)')  #Error




------art_269_21242482.1321237829356
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div>Binding#with</div><div><br></div><div>&nbsp; &nbsp; def with(_local_variables)</div><div>&nbsp; &nbsp; &nbsp; eval("Proc.new{ |#{_local_variables.keys.join(',')}| binding }").call(*_local_variables.values)</div><div>&nbsp; &nbsp; end</div><div><br></div><div>Try it:</div><div><br></div><div>&nbsp; &nbsp; b = binding.with(:a=&gt;1)</div><div>&nbsp; &nbsp; b.eval('a') &nbsp;#=&gt; 1<br></div><div><br></div><div>Now, it there a way to addyield" to the binding? I tried:</div><div><br></div><div><div>&nbsp; def with(_local_variables, &amp;_yields)</div><div>&nbsp; &nbsp; eval("lambda{ |#{_local_variables.keys.join(',')},&amp;yields| binding }").call(*_local_variables.values, &amp;_yields)</div><div>&nbsp; end</div></div><div><br></div><div><div style="border-style: initial; border-color: initial; ">&nbsp; &nbsp; b = binding.with{ |x| x+x}</div><div style="border-style: initial; border-color: initial; ">&nbsp; &nbsp; b.eval('yields[1]') &nbsp;#=&gt; 2<br></div></div><div style="border-style: initial; border-color:nitial; "><br></div><div style="border-style: initial; border-color: initial; ">but</div><div style="border-style: initial; border-color: initial; "><br></div><div style="border-style: initial; border-color: initial; ">&nbsp; &nbsp; b.eval('yield(1)') &nbsp;#=&gt; Error<br></div><div style="border-style: initial; border-color: initial; "><br></div><div style="border-style: initial; border-color: initial; "><br></div><div><br></div>
------art_269_21242482.1321237829356--

------art_268_26888015.1321237829355--