Morning,
anyone who could help me with "tricky" function call ?
Jiri Bruchanov
01/29/2020, 10:31 AM
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 {}
Jiri Bruchanov
01/29/2020, 10:32 AM
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)
Jiri Bruchanov
01/29/2020, 10:34 AM
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) {}