Daniel Nugent wrote:
> table_name = "CUSTOMERS"
> x = promise {table_name.dup}
> table_name = "MONKEYS"
> puts x
> =>"CUSTOMERS"
> 
> Would avoid the problem.  Though it's good to point out that you
> likely want to avoid changing the state of any variable that's
> captured by a promise closure (unless of course you plan on exploiting
> just that).

Hmmm ... I just tried it and got "MONKEYS" for the result.  It makes 
sense becase by the time table_name is dup'ed in the promise, it has 
already been modified.

This would do it:

   def table_promise(name)
     promise { name }
   end

   table_name = "CUSTOMERS"
   x = table_promise(table_name)
   table_name = "MONKEYS"
   puts x  # => "CUSTOMERS"

--
-- Jim Weirich



-- 
Posted via http://www.ruby-forum.com/.