From: Morton Goldberg Date: 2006-09-06T23:23:13+09:00 Subject: Re: How to take output of eval into a string? On Sep 6, 2006, at 9:02 AM, Anil Wadghule wrote: > #code > a = "puts 'I like Ruby'" > b = eval(a) > puts b > > after running above code, it gives output > > I like Ruby > nil > > the above code prints b a nil, I want output of eval into a string! > > How to do that? Please help! > > Regards, > Anil Wadghule > -- > Don't live to geek; geek to live. > http://anildigital.blogspot.com Your code is equivalent to ... b = puts 'I like Ruby' puts b ... and produces the same results, which is nil because puts always returns nil. Eval returns whatever object comes out of its evaluation, which can be any kind of an object. You can't count on it returning a string. Exactly what are you trying to capture into a string? Regards, Morton