Last active
April 6, 2018 00:58
-
-
Save creaaa/f7a6ab2be19a48fc7f5de19b1610139e to your computer and use it in GitHub Desktop.
え、当たり前??? でもこれが Array#flatMap(_:)<SegmentOfResult : Sequence> を理解する最大にして最後のキーとなるのだ!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [1,2,3] | |
a.append(contentsOf: [4,5]) | |
print(a) // [1,2,3,4,5] // 見ての通り、[4,5]の配列がflattenされた後、追加されている!!!!!! これの理解がのちのち超大事!!! | |
なぜなら、`Array#flatMap(_:)<SegmentOfResult : Sequence>` は、その内部で `Array.append(contentsOf_:)` を使っているため、 | |
`append(contentsOf_:)` を理解しておかないと、挙動を追う時ハマるから!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment