Re: Variable in string in array

2012-08-17 Thread Robert Klemme
On Fri, Aug 17, 2012 at 1:06 AM, Dave Castellano 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 > spe

Re: Variable in string in array

2012-08-15 Thread Robert Klemme
Please trim your quotes. Thank you! On Wed, Aug 15, 2012 at 6:07 PM, Dave Castellano wrote: > I want to place it in the array as a string, evaluate it later... > eg: > > age = "11" > puts array[0] The simplest would be array = [ lambda {|age| "An #{age} year old..."} ] Then you can do puts

Re: Variable in string in array

2012-08-15 Thread Robert Klemme
On Wed, Aug 15, 2012 at 2:46 PM, Dave Castellano wrote: > Anybody know how to embed a #{} in a string and then place the string in > an array? > > eg. > > array =["An #{age} year old..."] > > returns > /Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/catch_e