hi guys i know how to print all of array element i...
# getting-started
t
hi guys i know how to print all of array element in one line
Copy code
val topStudents = arrayOf("Jake", "Jesse", "Matt", "Alec")
names.forEach { println(it) }
but how to do in this condition.
Copy code
val allStudents = setOf {
      "Michael",
      "Kim",
      topStudents <= i don't know how to retrieve topStudent each names likes "Michael" and "Kim" 
}



// the result what i want is 
val allStudents = setOf {
      "Michael",
      "Kim",
      "Jake",
      "Jesse",
      "Matt",
      "Alec"
}
i
Copy code
val topStudents = arrayOf("Jake", "Jesse", "Matt", "Alec")

    val allStudents = setOf(
        "Michael",
        "Kim"
    ) + topStudents.toSet()

    allStudents.forEach { println(it) }
t
thanks @Ivan Kubyshkin [JetBrains]
b
.toSet()
is not necessary for
topStudents
, it can be just
Copy code
val allStudents = setOf(
        "Michael",
        "Kim"
    ) + topStudents
👍 1
d
Copy code
setOf(
    "Michael",
    "Kim",
    *topStudents
)
5