Challange 1 Chapter 20 - Why type-parameter?

Could someone explain why I need the second parameter “type” in the subscript below.
I’m sure there’s a perfectly obvious explanation, but I don’t get it…

//Why do we need the second parameter type?
extension Array {
subscript(index: Int, type: Bool) → (String, String)? {
guard let value = self[index] as? Int, type else {
return nil
}
switch (value >= 0, abs(value) % 2) {
case (true, 0):
return (“positive”, “even”)
case (true, 1): return (“positive”, “odd”)
case (false, 0):
return (“negative”, “even”)
case (false, 1):
return (“negative”, “odd”)
default:
return nil
}
}
}

let numbers = [-2, -1, 0, 1, 2]
numbers[0, true]
numbers[1, true]
numbers[2, false]
numbers[3, true]
numbers[4, true]

My best guest is that it’s there to illustrate that you can have subscripts with multiple arguments.

If you have any subscript with false as the second parameter, it will return nil (from the guard else statement). I don’t think there’s anymore to it.

Hope it helps.

It appears to me that the second argument is ignored. It isn’t referenced anywhere in the new subscript code and you get the same answer regardless of its setting to true or false. I believe it is there to differentiate the new array subscripting method from the built-in subscript. Using just “array[index]” does not allow the compiler to decide which subscript version to use.

I’m the author of this exercise, challenge and chapter and the explanation is a very simple one after all: I have indeed used the second parameter so that the compiler can tell the difference between my custom subscript on the Array class and the standard one for it which takes an Int parameter and argument as the array’s current element and item’s specific, associated and corresponding index (You can think of the whole thing as subscript overloading which is a very similar process compared to method overloading in object oriented programming).