3

ループとヒアドキュメントを実行できますか、次のようになります。

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

ありがとう

4

1 に答える 1

6
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!
于 2010-11-27T22:49:41.230 に答える