Generics


Generic & Mutating (diff in Any)

https://youtu.be/fB8_4GaS5Bg

https://youtu.be/J0SBrYzTqfg





class Stack<T> {

    var arr: [T] = []

    func push(_ item: T) {

        arr.append(item)

    }

    func remove(at index: Int) {

        arr.remove(at: index)

    }

}



let stack_1 = Stack<Int>()

stack_1.push(5)

stack_1.remove(at: 0)




Comments

Popular posts from this blog

SubString in Swift

PUSH Notification