Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

String interpolation in Ruby doesn't work?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...