map
¶
The map
filter applies an arrow function to the elements of a sequence or a
mapping. The arrow function receives the value of the sequence or mapping:
マップ フィルターは、矢印関数をシーケンスまたはマッピングの要素に適用します。アロー関数は、シーケンスまたはマッピングの値を受け取ります。
1 2 3 4 5 6 7 |
{% set people = [
{first: "Bob", last: "Smith"},
{first: "Alice", last: "Dupond"},
] %}
{{ people|map(p => "#{p.first} #{p.last}")|join(', ') }}
{# outputs Bob Smith, Alice Dupond #}
|
The arrow function also receives the key as a second argument:
アロー関数も 2 番目の引数としてキーを受け取ります。
1 2 3 4 5 6 7 |
{% set people = {
"Bob": "Smith",
"Alice": "Dupond",
} %}
{{ people|map((value, key) => "#{key} #{value}")|join(', ') }}
{# outputs Bob Smith, Alice Dupond #}
|
Note that the arrow function has access to the current context.
アロー関数は現在のコンテキストにアクセスできることに注意してください。
Arguments ¶
arrow
: The arrow functionarrow: アロー関数