VOOZH about

URL: https://www.geeksforgeeks.org/scala/scala-set-take-method-with-example/

⇱ Scala Set take() method with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Scala Set take() method with example

Last Updated : 18 Oct, 2019
The take() method is utilized to return a set consisting of first 'n' elements of the set.
Method Definition: def take(n: Int): Set[A] Where 'n' is specifies the number of element to select. Return Type: It returns a set consisting of first 'n' elements of the set.
Example #1:
Output:
Set(5, 1)
Example #2:
Output:
Set(41, 12, 23)
Comment

Explore