你能做一个循环和here-doc,像这样:
array.each do |ele|
a=<<-TEXT
ele
some stuff
TEXT
end谢谢
发布于 2010-11-28 06:49:41
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!https://stackoverflow.com/questions/4294289
复制相似问题