最佳答案
Ruby 新手,戴上你的新手手套。
Is there any difference (obscure or practical) between the following two snippets?
my_array = [:uno, :dos, :tres]
my_array.each { |item|
puts item
}
my_array = [:uno, :dos, :tres]
my_array.each do |item|
puts item
end
I realize the brace syntax would allow you to place the block on one line
my_array.each { |item| puts item }
但除此之外,还有什么令人信服的理由使用一种语法而不是另一种语法吗?