From: Stefan Codrescu Date: 2012-08-19T08:18:33+09:00 Subject: Re: Access returned value in a string? Why don't you set a variable as a = rand(3..15) Then you can use a in the string and outside of it. StefaN On Aug 18, 2012, at 3:56 PM, Dave Castellano wrote: > Can I access the returned value in a string? > > eg > questions = [ > "A slide is placed #{rand(3..15)} cm to the left of a lens.", > ... > ] > > puts questions[0] >>> A slide is placed 12 cm to the left of a lens. > > I need to pass 12 to a function. Do I have to extract it from the > string or is it stored somewhere I can access it? > > -- > Posted via http://www.ruby-forum.com/. >