A
A
aminought2015-10-18 15:31:05
ruby
aminought, 2015-10-18 15:31:05

Does Ruby have double interpolation?

Good afternoon. Does Ruby have double interpolation when typing?

p = "my param"
s = $stdin.gets.strip! # #{p}
puts "Hi #{s} hi!" # Я хочу "Hi my param hi!"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikolai Markov, 2015-10-18
@aminought

That won't work. Interpolation is just syntactic sugar. You need to run your input through eval.

R
Roman Mirilaczvili, 2015-10-18
@2ord

Then why not
puts "Hi #{p} hi!"

E
Eugene Burmakin, 2015-10-18
@Freika

yield, if I understand correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question