【发布时间】:2010-02-12 07:49:34
【问题描述】:
可能的重复:
Using do block vs brackets {}
What is the difference or value of these block coding styles in Ruby?
为什么会这样:
test = [1, 1, 1].collect do |te|
te + 10
end
puts test
有效,但无效:
puts test = [1, 1, 1].collect do |te|
te + 10
end
但这是可行的:
puts test = [1, 1, 1].collect { |te|
te + 10
}
对于我不知道的块,do/end 构造和 { } 构造之间有区别吗?
【问题讨论】:
-
这个问题与StackOverflow.Com/questions/533008 和StackOverflow.Com/questions/2122380 完全相同,可能还有十几个问题。
-
我看到的最受好评的副本:stackoverflow.com/questions/5587264/…
标签: ruby programming-languages syntax