------art_1437_18131298.1321136255790
Content-Type: multipart/alternative; 
	boundary---art_1438_24940715.1321136255790"

------art_1438_24940715.1321136255790
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Saturday, November 12, 2011 4:10:09 PM UTC-5, Quintus wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Am 12.11.2011 21:19, schrieb Intransition:
> > Is there a way to "merge" the binding to do something like:
> > 
> > eval('a + b', binding1 + binding2)  #=> 3
>
> Not sure if that exactly what you want, but this works:
>
>   binding1.eval("a + binding2.eval('b')") #=> 3
>
> This is not 'merging' the two bindings, it rather opens the second
> binding inside the first one.
>

My usecase is for template generation. For example ERB, it's render method 
takes *a* Binding.

 

> Regarding Binding#eval, is there a specific reason why it can take a
> block instead of a string, the same way e.g. Module#instance_eval does?
>

Actually I suggested that feature on ruby issue tracker and I believe the 
anwser given was YAGNI.

If it were possible could it solve this?



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

On Saturday, November 12, 2011 4:10:09 PM UTC-5, Quintus wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>Hash: SHA1<p>Am 12.11.2011 21:19, schrieb Intransition:<br>&gt; Is there a way to "merge" the binding to do something like:<br>&gt; <br>&gt; eval('a + b',inding1 + binding2) &nbsp;#=&gt; 3</p><p>Not sure if that exactly what you want, but this works:</p><p>&nbsp; binding1.eval("a + binding2.eval('b')") #=&gt; 3</p><p>This is not 'merging' the two bindings, it rather opens the second<br>binding inside the first one.</p></blockquote><div><br></div><div>My usecase is for template generation. For example ERB, it's render method takes <i>a</i> Binding.</div><div><br></div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>Regarding Binding#eval, is there a specific reason why it can take a<br>block instead of a string, the same way e.g. Module#instance_eval does?</p></blockquote><div><br></div><div>Actually I suggested that feature on ruby issue tracker andelieve the anwser given was YAGNI.</div><div><br></div><div>If it were possible could it solve this?<br></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><p></p><p></p><p></p></blockquote>
------art_1438_24940715.1321136255790--

------art_1437_18131298.1321136255790--