Рубин-док с петлей - PullRequest
       9

Рубин-док с петлей

3 голосов
/ 28 ноября 2010

Можете ли вы сделать цикл и вот документ, что-то вроде этого:

array.each do |ele|
  a=<<-TEXT
   ele
   some stuff
  TEXT
end

Спасибо

1 Ответ

6 голосов
/ 28 ноября 2010
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!
...