Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String interpolation in Ruby doesn't work?

Tags:

string

ruby

Recently I shifted to Ruby 2.0.0 from Ruby 1.9.3.

In 1.9.3 we were used to perform string interpolation using: 'http://#{get_host_name}.com, but since moving to 2.0.0, it seems to be not working.

Can anyone tell me if the syntax changed? How can I perform string interpolation in Ruby 2.0.0?

like image 506
User16119012 Avatar asked Dec 05 '22 10:12

User16119012


1 Answers

Regardless of which version of Ruby you're using, string interpolation doesn't happen in single-quoted strings. Use double-quoted strings or %Q-style strings.

like image 149
Darshan Rivka Whittle Avatar answered Dec 23 '22 22:12

Darshan Rivka Whittle