How can I do something like this? Take the first n elements from an array:
newNumbers = numbers[0..n]
Currently getting the following error
This works for me:
var test = [1, 2, 3]
var n = 2
var test2 = test[0..
Your issue could be with how you're declaring your array to begin with.
EDIT:
To fix your function, you have to cast your Slice to an array:
func aFunction(numbers: Array, position: Int) -> Array {
var newNumbers = Array(numbers[0..