On Fri, Aug 17, 2012 at 1:06 AM, Dave Castellano <[email protected]> wrote:
> Is it possible to pass elements in an array (eg 20,50 ) to the function
> number_range(min,max) and have the returned value used in the variable
> |age| below...
>
>
> def number_range(min,max)         # Chooses a random number within
> specified range.
>   num = min + rand(max - min)
> end
>
> array = [ lambda { |age| "An #{age} year old..."}, 20, 50 ]
>
> puts array[0][age returned from number_range method]

Yes, exactly like that.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to