Bronze Challenge

Add a filter(_:) method to your Stack structure. It should take a single argument, a closure that takes an Element and returns a Bool, and return a new Stack<Element> that contains any elements for which the closure returns true.

Get Swift Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.