There's more...

The standard library also overloads a - operator for the Collection type. We could use it to subtract some elements from the collection. For example, we could use it like this:

val receivedMessages = allMessages - sentMessages
receivedMessages.forEach { (text, _) ->
println(text)
}

And we would get the following output:

Let's go out of town and watch the stars tonight!
Excelent!

We could also use the standard for loop to implement the iteration:

for (msg in allMessages) {
println(msg.text)
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.246.72