proc = Proc.new { |hash| puts "#{hash[:bar]}" }

proc.call(hash)

Martin Emde
Tw: @martinemde


On Sun, Aug 23, 2009 at 2:56 PM, Guyren G Howe <guy...@gmail.com> wrote:

>
> I want to take a proc, retain its closure, and call it, but rather
> than pass it args in the normal fashion, I want to have it merge a
> hash into its bindings also.
>
> Something like this:
>
> foo = "FOO"
>
> h = {:bar => "BAR"}
>
> p = Proc.new do
>        puts "#{foo}#{bar}"
> end
>
> p.call_with_hash h
>
> #prints FOOBAR
>
> Can't quite see how to do it. Anyone?
>
> Regards,
>
> Guyren G Howe
> Relevant Logic LLC
>
> guyren-at-relevantlogic.com ~ http://relevantlogic.com ~ +1 512 784 3178
>
> Ruby/Rails,  REALbasic, PHP programming
> PostgreSQL, MySQL database design and consulting
> Technical writing and training
>
> Read my book, Real OOP with REALbasic: <
> http://relevantlogic.com/oop-book/about-the-oop-book.php
>  >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
sdruby@googlegroups.com
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to