I never really know where to put me doing weird th...
# getting-started
r
I never really know where to put me doing weird things with the type system, so it'll go here. I'm trying to write an extension function for tracing for
Copy code
posthog().capture("reader_disconnected", mapOf("unitName" to logName, "voltage" to previousBattery))
fun:
Copy code
fun PostHog.capture(s: String, mapOf: Map<String, Any>) {
    capture(s, mapOf)
}
But the compiler doesn't seem to pick it up, even though the IDE suggested it.
Copy code
Type mismatch.
Required: Properties?
Found: Map<String, {Comparable*>? & java.io.Serializable?}>
r
is there an overload of the
capture
function accepting a
Properties
object? If so, if it's a
java.util.Properties
object, that might cause the conflicts because that class extends
Hashtable<Object, Object>
, which in turn implements
Map<Object, Object>
r
Shouldn't it work without the extension function? 🤔
r
I don't know the API of the Posthog class, but no, not if it accepts a
Properties
object specifically. A
Properties
is a
Map
, but a
Map
doesn't have to be a
Properties
🙂
r
Ah, understood. Lemme see if I can convert.
Dunno what I just did, but my IDE just froze 😶‍🌫️
🥶 1