Created
November 24, 2016 01:12
-
-
Save toshi0383/15ee1b3eb03e57e99ec96cc08fbd2b9d to your computer and use it in GitHub Desktop.
SwiftのArrayは暗黙的にcountの型で長さが制限される。countはIntなので、64bitのMacBookProだとINT64_MAXが限界になる。ということを知った。 #CodePiece
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
import Foundation | |
let a = (0..<UINT32_MAX).lazy.map{$0} | |
print(a.count) // 4294967295 | |
let b = (0..<INT64_MAX).lazy.map{$0} | |
print(b.count) // 9223372036854775807 | |
let bb = (0...INT64_MAX).lazy.map{$0} | |
print(bb.count) // <= EXC_BAD_INSTRUCTION | |
let c = (0..<UINT64_MAX).lazy.map{$0} | |
print(c.count) // <= EXC_BAD_INSTRUCTION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment