Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 543 Bytes

10.3.md

File metadata and controls

28 lines (21 loc) · 543 Bytes

Collectableプロトコル

  • Enumerableプロトコル: 与えられたコレクションの要素を得られる
  • Collectableプロトコル: 要素を挿入してコレクションを作れる
    Enum.into でアクセスして内包表記で使う

範囲の各要素をリストに追加する

> Enum.into 1..5, []
[1, 2, 3, 4, 5]
> Enum.into 1..5, [100, 101]
[100, 101, 1, 2, 3, 4, 5]

標準入力を標準出力に遅延コピーする

> Enum.into IO.stream(:stdio, :line), IO.stream(:stdio, :line)
a
a
b
b


0
0