in which i have ```class Stack<T> { val ...
# announcements
s
in which i have
Copy code
class Stack<T> {
    val stack = LinkedList<T>()

    fun addLast(value: T) {
        stack.append(value)
    }
    fun push(value: T) {
        stack.append(value)
    }
    fun peek(): T? {
        return stack.first()?.value
    }
    fun pop(): T? {
        return stack.removeAtIndex(0)
    }
    fun test() {
        val s = Stack<String>()
        s.push("John")
        println(s)
        s.push("Carl")
        println(s)
        println("peek item: ${s.peek()}")
        println("pop item: ${s.pop()}")
        println("peek item: ${s.peek()}")
    }

    fun contains(s: T?): Boolean = stack.contains(s)

    override fun toString(): String = stack.toString()

    fun iterator() = stack.iterator()

    fun forEach(action: (T?) -> Unit) = stack.forEach(action)
}
🧵 2