Scala Stack distinct() method with example
In Scala Stack class, the distinct() method is utilized to delete the duplicate elements from the given stack. Method Definition: def distinct: Stack[A] Return Type: It returns a new stack with only distinct elements. Example #1: // Scala program of distinct() // method // Import Stack import scala.