def double(a)
a*2
end
method_object = method(:double)
,這裏是我的問題,請問這是怎麼代碼:Array#map有參數如何做這樣的事情?
[1,3,5,6].map(&method_object)
實現
[1,3,5,6].map {|x| method_object.call(x)}
Ruby的文檔中
相同的結果,陣列#地圖只能有塊,不正常參數
ary.collect {|item| block } → new_ary ary.map {|item| block } → new_ary ary.collect → an_enumerator ary.map → an_enumerator