Created
April 5, 2018 22:59
-
-
Save andr3a88/192ab22b76dee83156109345e4c15c96 to your computer and use it in GitHub Desktop.
Array slice
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 test = [1, 2, 3] | |
var n = 5 | |
let limit = n > test.count ? test.count : n | |
var test2 = test[0..<limit] | |
var test3 = test.prefix(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment