From: Dave Castellano Date: 2012-08-17T21:15:12+09:00 Subject: Re: variable from array to function to array The bigger picture... I am saving multiple question templates in a array and need to store all the info (the question, the min and max ranges, the units of measure etc assoc with each question. The associated info is used to build the question ... eg in question one, need to pass 20,40 to number_range(min,max) and use the returned value as u. def number_range(min,max) min + rand(max - min + 1) **Thanks! end array =[ [ lambda {|u,u_unit| "A slide is placed #{u} #{u_unit} to the left of a lens...", 20, 40, "cm"], [ lambda {|v,v_unit| "An image is in focus #{v} #{v_unit} to the right of a...", 10, 25, "mm], [.... ] puts array[n][variable returned from number_range method] >> A slide is placed 25 cm... Also, def random_age_string(range) "A #{rand(range)} year old" end puts random_age_string(20..40) Does not work as I am not able to embed "#{}" in a string in an array... it just returns the string without evaluating... -- Posted via http://www.ruby-forum.com/.