------ extPart_000_42DB_01CCC5FD.7C37A100 Content-Type: text/plain; charset so-8859-1" Content-Transfer-Encoding: quoted-printable Da: Intransition [mailto:transfire / gmail.com] Inviato: luned14 novembre 2011 03:31 A: ruby-talk ML; ruby-talk-google / googlegroups.com Oggetto: Binding#with Binding#with def with(_local_variables) eval("Proc.new{ |#{_local_variables.keys.join(',')}| binding }").call(*_local_variables.values) end Try it: b = binding.with(:a=>1) 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 = binding.with{ |x| x+x} b.eval('yields[1]') #=> 2 but b.eval('yield(1)') #=> Error -- Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Conto Arancio al 4,20%. Zero spese e massima liberta', aprilo in due minuti! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=11919&d=29-12 ------ extPart_000_42DB_01CCC5FD.7C37A100--