------ art_932_29786049.1321288653687 Content-Type: multipart/alternative; boundary --- art_933_4604775.1321288653687" ------ art_933_4604775.1321288653687 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Sunday, November 13, 2011 10:16:37 PM UTC-5, Josh Cheek wrote: > > Note I had to explicitly define this in Binding to avoid the private method > invocation. > Sorry, I should have clarified that. Yes, that is the intent. > > 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 > > > > > Note that this didn't work for me unless I passed a hash to Binding#with, > because otherwise the syntax it generates looks like `lambda{ |,&yields| > binding }` which is a syntax error > Good point, thanks. ------ art_933_4604775.1321288653687 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sunday, November 13, 2011 10:16:37 PM UTC-5, Josh Cheek wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>Note I had to explicitly define this in Binding to avoid the private method<br>invocation.</p></blockquote><div>Sorry, I should have clarified that. Yes, that is the intent.</div><div> <br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>> Now, it there a way to add a "yield" to the binding? I tried:<br>><br>> ef with(_local_variables, &_yields)<br>> eval("lambda{ |#{_local_variables.keys.join(<wbr>',')},&yields| binding<br>> }").call(*_local_variables.<wbr>values, &_yields)<br>> end<br>><br>> b = binding.with{ |x| x+x}<br>> b.eval('yields[1]') #=> 2<br>><br>><br>Note that this didn't work for me unless I passed a hash to Binding#with,<br>because otherwise the syntax it generates looks like `lambda{ |,&yields|<br>binding }`hich is a syntax error</p></blockquote><div>Good point, thanks.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p></p><p></p><p></p><p></p><p></p></blockquote> ------ art_933_4604775.1321288653687-- ------ art_932_29786049.1321288653687--