Re: Replacing values
- From: Robert Klemme <shortcutter@xxxxxxxxxxxxxx>
- Date: Thu, 19 Feb 2009 10:08:45 -0500
2009/2/19 Ashikali Ashikali <ashikali.m@xxxxxxxxx>:
Andrew Timberlake wrote:
On Thu, Feb 19, 2009 at 3:41 PM, Ashikali Ashikali
<ashikali.m@xxxxxxxxx>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: <string>.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
.
- References:
- Replacing values
- From: Ashikali Ashikali
- Re: Replacing values
- From: Andrew Timberlake
- Re: Replacing values
- From: Ashikali Ashikali
- Replacing values
- Prev by Date: Re: I have to be missing something simple here.
- Next by Date: Re: Replacing values
- Previous by thread: Re: Replacing values
- Next by thread: Re: Replacing values
- Index(es):
Relevant Pages
|