https://kotlinlang.org logo
#announcements
Title
# announcements
c

Czar

11/01/2017, 1:13 PM
Hi. For a subtree of our class hierarchy we have interface method
apply
whose argument is a SAM from guava. Since some of us started using K we bump into the conflict with Kotlin's
apply
quite often. I'm considering the resolution options and so far found only two. Did I miss anything? 1. rename member
apply
to something like
applyFunction
(involves convincing several teamleads who do not use K ) 2. specify the receiver type (
someInstanceOfBase.apply<Base> { ... }
) (suggested by @marstran) 3. accept that this is the reality and use
also
instead of
apply
4. duplicate Kotlin's
apply
and rename that (suggested by @karelpeeters) Here's the recipe for the disaster at hand 🙂 (irrelevant parts omitted for brevity)
Copy code
import com.google.common.base.Function;
public abstract class Base {
	public <T, F> T apply(Function<F, T> function) {
		return function.apply((F) this);
	}
}
s

Shawn

11/01/2017, 1:20 PM
I’m kind of curious as to what conditions the
apply
conflict occurs - any chance we could get a code sample?
c

Czar

11/01/2017, 1:26 PM
@Shawn sure, I've updated the OP.
👍 1
Huh. Just got an idea...
import kotlin.apply as kapply
This works, but I'm not sure yet how I feel about it and where to put it in the options list 🙂 So far renaming member apply is still my number one, unfortunately.
7 Views