能否举出各种例子,关于 ruby 可以做一件事用很多方法?
#; python way
for i in 0..5
puts "hello"
end #; using block
5.times do
puts "hello"
end #; each
(["hello"] * 5).each do |item|
puts item
end #; print
print "hello\n"*5#; beginner's way
puts "hello"
puts "hello"
puts "hello"
puts "hello"
puts "hello"