Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Functional Collection Patterns | Map Pattern

概要

Map Pattern

詳細

Collectionの各要素を1対1で変換するFunctionを作成すること。
Rubyではmap(collect)が該当。

サンプル

list = [1, 2, 3, 4]
p list.map {|e|e + 1}

結果

[2, 3, 4, 5]