以下是常見的Ruby block用法: result = 0 array = [2,3,4,5,6] array.each do |value| result = result + value end result # => 20.
確定! 回上一頁