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)
}