chansek
06/12/2019, 1:56 PMdavid.bilik
06/12/2019, 1:57 PMTest classdavid.bilik
06/12/2019, 1:57 PMmain to eg. init of your Test class it would workchansek
06/12/2019, 2:01 PMCzar
06/12/2019, 4:23 PMpackage com.example
class Test {
operator fun String.get(range: IntRange) = substring(range)
}
class Test2 {
companion object {
operator fun String.get(range: IntRange) = substring(range)
}
}
fun main() {
val x = "test"
val y = with(Test()) { x[2..3] }
val z = with(Test2) { x[2..3]}
}thana
06/13/2019, 9:12 AMget without with or similar? i do understand the result of the call but i can't figure out how i would explicitly write it... Test().get() doesn't work. Test()."test"[] doesn't even make any sense...Czar
06/13/2019, 9:30 AMget here is double scoped.thana
06/13/2019, 10:12 AM