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.
Answer 51d2afb1282ae33a990093c5. Single-quoted and double-quoted strings are (almost) equivalent in Ruby. Of course, you have to escape \' inside single-quoted strings and \" inside double-quoted strings.
Alternate double quotesThe %Q operator (notice the case of Q in %Q ) allows you to create a string literal using double-quoting rules, but without using the double quote as a delimiter. It works much the same as the %q operator. Just like double quotes, you can interpolate Ruby code inside of these string literals.
You can use the + operator to append a string to another. In this case, a + b + c , creates a new string. Btw, you don't need to use variables to make this work.
Probably you mean:
expectedValue = "\""+expectedValue+"\""
or more in ruby style:
expectedValue = "\"#{expectedValue}\""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With