From: Robert Klemme Date: 2009-02-20T00:08:45+09:00 Subject: Re: Replacing values 2009/2/19 Ashikali Ashikali : > Andrew Timberlake wrote: >> On Thu, Feb 19, 2009 at 3:41 PM, Ashikali Ashikali >> wrote: >> >>> "This is 18" >>> >>> Question , >>> How can I convert '' value to "" value . >> Your question is not clear >> >> Changing a ' to a " is as simple as typing a different character. >> In your example you are typing a string literal so typing it differently >> should get you the results you're looking for. >> >> If you're working on another string, you can do: .gsub(/'/, '"') >> >> Andrew Timberlake >> http://ramblingsonrails.com >> http://www.linkedin.com/in/andrewtimberlake >> >> "I have never let my schooling interfere with my education" - Mark Twain > > my question is not that converting ' to " . Apart from this , > when we declare string as "" , our ruby replace the variable value into > actual > value like this , > c = 10 > b = "This is #{c}" > puts b > #it prints "This is 10" > In above, it start to execute and replace c variable value so it prints > , > "This is 10" . > > m = 'This is #{d}' #single quote > In above , it does not replace d variable( not yet created ) . No, it does not do the replacement because you used a single quoted string. > d = 15 > #if I do puts m > 'This is #{d}' > > What I want is when we converting ' to " it start to replace the value d > . > is there any method available to do this . To do what? Are you thinking of something like this? irb(main):001:0> a = 'This is #{b}' => "This is \#{b}" irb(main):002:0> b = 10 => 10 irb(main):003:0> eval("\"#{a}\"") => "This is 10" robert -- remember.guy do |as, often| as.you_can - without end