Is there a way with which I can call the reduction function in an array of tuples to find the maximum value?
for instance
struct Gate{ var maxedOpenGates = 1 var GatesOpen : [(openOrdered : Int, gateNum : Int )] = [] init(defaultSelected : Int = 0){ GatesOpen.append(openOrdered : 1, gateNum : defaultSelected) } private func manipulateGates(gates : [SegmentButton]){ for i in GatesOpen{ gates[i.gateNum].toggleSelected() } } mutating func openGate(index : Int, buttons : [SegmentButton]){ if GatesOpen.count < maxedOpenGates{ GatesOpen.append( openOrdered: GatesOpen.count , gateNum: index) }else{
where I'm trying to reduce based on openOrdered
let lastGate = GatesOpen.reduce(Int.min,{ max($0,$1) })
source share