Можете ли вы сделать цикл и здесь-doc, что-то вроде этого:
array.each do |ele|
a=<<-TEXT
ele
some stuff
TEXT
end
Спасибо
Можете ли вы сделать цикл и здесь-doc, что-то вроде этого:
array.each do |ele|
a=<<-TEXT
ele
some stuff
TEXT
end
Спасибо
array = %w[one two many]
array.each do |ele|
a=<<-TEXT
This is some text and
this --> #{ele} <-- is the ele!
TEXT
puts a
end
приводит к
This is some text and
this --> one <-- is the ele!
This is some text and
this --> two <-- is the ele!
This is some text and
this --> many <-- is the ele!
a
в своем вопросе; Я случайно добавил puts
, чтобы понять, что происходит :)
- person lbz; 28.11.2010
puts
вне цикла, если вы не назначите a
внутри цикла и не сделаете each
map
. Я бы даже предпочел именно так.
- person hurikhan77; 28.11.2010