Bob Redity
Bob Redity

Reputation: 621

For some reason Set<String> does not have "contains"

Its init in the constructor and it returns set of the strings.

private val listener: () -> Set<String> = {
    NotificationManagerCompat.getEnabledListenerPackages(context)
}

But for some reason I am not able to call .contains() function when I'm calling listener.contains("package") It says enter image description here

Upvotes: 1

Views: 245

Answers (1)

Ben Shmuel
Ben Shmuel

Reputation: 2009

listener is a lambda of type () -> Set<String

in order to use contains() you need listener's value which is Set<>

You can achieve this buy using invoke() as @Михаил Нафталь mentioned:

listener.invoke().contains("value")

or:

listener().contains("value")

Invoking a function type instance

Upvotes: 3

Related Questions