Skip to Content
Learn
Sets
Review

Great job! In this lesson, we’ve learned the following concepts:

  • A set is an unordered Kotlin collection that stores unique elements.
  • An immutable set is declared with the setOf keyword and indicates a set whose values cannot change throughout a program.
  • A mutable set is declared with the mutableSetOf keyword and indicates a set whose values can be altered.
  • Elements within a set can be accessed using the elementAt() or elementAtOrNull() functions.
  • The addAll() and add() functions are used to add elements to a collection.
  • The first() and last() functions return the first and last elements of a collection.
  • The clear() function removes all elements from a collection.

You’ve now covered the second major collection that exists in Kotlin as well as many other programming languages. Feel free to utilize the empty Review.kt file and output terminal on the right to hone your understanding of sets and practice writing Kotlin code.

Instructions

Click Up Next when you’re ready to move on.

Folder Icon

Take this course for free

Already have an account?