From: Stefan Codrescu Date: 2012-08-19T08:33:38+09:00 Subject: Re: Access returned value in a string? 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. > questions = > "A slide is placed #{rand(3..15)} cm to the left of a lens." 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/. >