There's have a Java library's class which has aVeryLongNameThatIDontWantToTypeEveryTime
. This class has a few static methods with generic names: get()
, abs()
etc.
Now I need to construct complicated calls with them in my kotlin code like this one:
aVeryLongNameThatIDontWantToTypeEveryTime.get(aVeryLongNameThatIDontWantToTypeEveryTime.abs(aVeryLongNameThatIDontWantToTypeEveryTime.get(...), aVeryLongNameThatIDontWantToTypeEveryTime.get(...)))
Now, I would like to use a local scoping function in order to not repeat myself so often. However, simply using
with(aVeryLongNameThatIDontWantToTypeEveryTime) {
get(abs(get(...), get(...)))
}
does not work: It complains that aVeryLongNameThatIDontWantToTypeEveryTime does not have a companion object. (Of course it doesn't, it's a Java class.)
The only "solution" is to globally import aVeryLongNameThatIDontWantToTypeEveryTime.*
in the file which isn't great since the method names are so generic and could collide.