Morning, anyone who could help me with "tricky" fu...
# announcements
j
Morning, anyone who could help me with "tricky" function call ?
Copy code
interface A
interface B

class AB : A, B

//v1
fun doSomething(
    entries: Array<AB>,
    id: Int = 0
) {

    //recursive call, how to call V2A ?
    //how to cast Array<AB> to Array<A && B>
    doSomething(entries, id)

    //call is fine, different fun name
    doSomething2(entries, id)

    //call is fine V2C, because of named arg
    doSomething(entries, idX = id)
}

//v2A
fun <T> doSomething(entries: Array<T>, id: Int = 0) where T : A, T : B {}

//v2B
fun <T> doSomething2(entries: Array<T>, id: Int = 0) where T : A, T : B {}

//v2C
fun <T> doSomething(entries: Array<T>, idX: Int = 0) where T : A, T : B {}
how to avoid recursiveness in the following block
Copy code
//recursive call, how to call V2A ?
    //how to cast Array<AB> to Array<A && B>
    doSomething(entries, id)
obviously different name would help, just wondering how to do it with keeping same name something like
Copy code
fun test(value:String) { test(value as Any) }
fun test(any:Any) {}
d
Try adding the recursive parameter -
doSomething<AB>(...)
Type parameter *
j
nice one, that helped