某天某人又在某群問,do是什么意思?
google了一把,發現有個解釋應該正確:
When the block is longer than one line, it's more readable to begin it with the do keyword and end it with the end keyword
看來do是block的用法,如果這個block一行寫不完就可以用do...end
例如:
[1,2,3].each { |i| puts i }可寫成
[1,2,3].each do |i|
puts i
end
google了一把,發現有個解釋應該正確:
When the block is longer than one line, it's more readable to begin it with the do keyword and end it with the end keyword
看來do是block的用法,如果這個block一行寫不完就可以用do...end
例如:
[1,2,3].each { |i| puts i }可寫成
[1,2,3].each do |i|
puts i
end
........................................................................