From: Brian Candler Date: 2012-08-25T16:36:32+09:00 Subject: Re: Access returned value in a string? Stefan Codrescu wrote in post #1072788: > Additionally you could do something like > questions = [ "a slide is placed #{a=rand(3..15), a} cm to the left of a > lens." > a could then be passed to some function. If you have not been using Ruby for a long time, you should probably test your answers before posting. Ruby is not C, and there is not a "comma operator" like C. What you have written will assign a two-element array to a. It's the same as: a = [rand(3..15), a] Because 'a' has not been assigned at this point, the value you get is a = [rand(3..15), nil] However, you *could* simply write: questions = [ "a slide is placed #{a=rand(3..15)} cm to the left of a lens." ] -- Posted via http://www.ruby-forum.com/.