CodeThisAndThat
CodeThisAndThat

Reputation: 25

Kotlin "Destructuring declaration initializer of type Any must have a 'component1()' function..."

I have a for each loop

for(conn in connection) {
   var(first,second,third) = reader.getLatency(conn,LocationAssignment)
}

Where reader.getLatency is

open class LatencyReader {
    companion object {
        fun getLatency(conn: Connection, locationAssignment: HashMap<String, String>): Any {
            return Triple(LatencyReader.MissingLatency, LatencyReader.MissingLatency, LatencyReader.MissingLatency)

        }

        val MissingLatency: Int = 9999
    }

How can I access each element of reader.getLatency(conn,LocationAssignment), most importantly I want to access the last element or the third of the triple.

Upvotes: 0

Views: 1207

Answers (1)

CodeThisAndThat
CodeThisAndThat

Reputation: 25

Sweeper said in a comment:

Why does getLatency return Any. It should return Triple<Int, Int, Int>, shouldn't it?

which was the solution.

Upvotes: 0

Related Questions