9

I need a string with double quotes

tried

expectedValue = "/""+expectedValue+"/""

but did not worked -

Throws below error -

NoMethodError: undefined method `/' for "/+expectedValue+":String

Please suggest.

2 Answers 2

22

Probably you mean:

expectedValue = "\""+expectedValue+"\""

or more in ruby style:

expectedValue = "\"#{expectedValue}\""
1
  • Would be also great if you accept some answer. To close this question.
    – zishe
    Jun 19, 2014 at 10:41
12

You can use %Q, or simply %

expectedValue = %Q{"#{expectedValue}"}

expectedValue = %|"#{expectedValue}"|

Reference: String literals

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.