Compare builtin `setOf` with Android's `keySet`?

54 Views Asked by At

Trying to ensure consistency concisely across my application. How do I check the bundle has the same keys as a set? - Or how do I construct a keySet succinctly for comparison?

import android.os.Bundle


fun main() {
    val expect = setOf("alpha", "beta")
    val bundle = Bundle()
    bundle.putCharSequence("alpha", "gamma")
    bundle.putCharSequence("beta", "zeta")
    assert(bundle.keySet() == expect)
    // Also tried `bundle.keySet().equals(expect)`
}

Output of println("Expected $expect got $keys"):

Expected [alpha, beta] got android.util.MapCollections$KeySet@48d26086
0

There are 0 best solutions below