I tried adding single quotes
array =[’ “An #{age} year old…” '] and this accepted the string but
the variable was also converted to a string, so lost as a variable.
I tried adding single quotes
array =[’ “An #{age} year old…” '] and this accepted the string
but
the variable was also converted to a string, so lost as a variable.
Thanks
The code snippet you post is correct, so whatever exception TextMate is
catching has been thrown from somewhere else:
age = 99
=> 99
array =[“A #{age} year old…”]
=> [“A 99 year old…”]
If the error originated in that line it can only be caused by invoking
method “age”. Do you have a stack trace?
I tried adding single quotes
array =[’ “An #{age} year old…” '] and this accepted the string but
the variable was also converted to a string, so lost as a variable.
Do you want the #{…} to be literally present in the String or do you
want to evaluate it when placing the String in the Array?
If the error originated in that line it can only be caused by invoking
method “age”. Do you have a stack trace?
I tried adding single quotes
array =[’ “An #{age} year old…” '] and this accepted the string but
the variable was also converted to a string, so lost as a variable.
Do you want the #{…} to be literally present in the String or do you
want to evaluate it when placing the String in the Array?
Kind regards
robert
I want to place it in the array as a string, evaluate it later…
eg:
array =[’ “An #{age} year old…” ']
age = “11”
puts array[0]
If the error originated in that line it can only be caused by invoking
method “age”. Do you have a stack trace?
I tried adding single quotes
array =[’ “An #{age} year old…” '] and this accepted the string but
the variable was also converted to a string, so lost as a variable.
Do you want the #{…} to be literally present in the String or do you
want to evaluate it when placing the String in the Array?
Kind regards
robert
I want to place it in the array as a string, evaluate it later…
eg:
array =[’ “An #{age} year old…” ']
age = “11”
puts array[0]
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