You can just do
table_name = “CUSTOMERS”
x = promise { table_name }
puts x
=> “CUSTOMERS”
though you have to then make sure that you leave that table_name
variable alone.
table_name = “CUSTOMERS”
x = promise { table_name }
table_name = “MONKEYS”
puts x
=> “MONKEYS”
From: Shashank D. [mailto:[email protected]]
Sent: Thursday, 23 February 2006 9:15 AM
To: ruby-talk ML
Cc: [email protected]
Subject: Re: [ANN] lazy.rb 0.9.5 -- transparent futures!
Hi,
I have a feature request (along with a quick-hack solution).
Please ignore if this is already done or sounds crazy. :-)
Problem: All the promises I make, cannot have any arguments ! !
So something like this is what I have in mind:
x = promise("CUSTOMERS") { |table_name|
long_running_query(table_name)}
Admitedly, in this one-liner it does not make much sense. But if
the block had many many lines of code and referred to the block variable
at multiple places, suddenly it would be mean more to me.
I have attached my hackish solution without really thinking all
the way thru.
Thanks,
-- Shashank
MenTaLguY <[email protected]> wrote:
I'd like to announce a new version of lazy.rb -- this one
offering
thread safety and transparent futures!
Here's the web site, complete with gem and tarball downloads,
plus a bit
of documentation:
http://moonbase.rydia.net/software/lazy.rb/
Bug reports would be very, very welcome.
Yahoo! Mail
Use Photomail
<http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=38867/*http://photomail
.mail.yahoo.com> to share photos without annoying attachments.