Re: Replacing values



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

.



Relevant Pages

  • Re: SQL
    ... Just a naked string. ... also that in this case it is not the context which determines the types, ... I.e. it is dynamic typing, ... PHP is an example of a dynamically-typed language (and frankly it is ...
    (comp.object)
  • Re: SQL
    ... Just a naked string. ... also that in this case it is not the context which determines the types, ... I.e. it is dynamic typing, ... interesting than math libraries IMO. ...
    (comp.object)
  • Re: Advice needed binary configuration files
    ... Just typing for something to do. ... convert the character buffer to the long type. ... And so on and so on till you get to the string. ... Regards, ...
    (microsoft.public.vc.mfc)
  • Re: replace substring
    ... The OP should tell how he got that invalid string literal. ... own typing, he should replace the backslashes with pairs of backslashes, ... on the course of copying each character to a separate character array. ...
    (comp.lang.c)
  • Re: SQL
    ... dynamic typing would bust relational. ... If you mean that the context typing system I showed does not have a ... Just a naked string. ... possible to mix in arrays too such that there is no hard difference ...
    (comp.object)