Dontsu
10/23/2023, 5:28 AMfun getPrice(
productCount : Int,
discount: Int,
limit = if (productCount == 12) 3 else 6
) {
// codes..
}
As you can see, the parameter limit
is determined by productCount
. I just wonder it would be a performance problem when runtime or compiler checks this function would often be changed or not.
Of course, Kotlin has immutable parameters in a function but the "if" can be a problem??Sam
10/23/2023, 7:30 AMRonny Bräunlich
10/23/2023, 7:30 AMpublic static void getPrice$default(MediaConsumedProcessor var0, int var1, int var2, int var3, int var4, Object var5) {
if ((var4 & 4) != 0) {
var3 = var1 == 12 ? 3 : 6;
}
var0.getPrice(var1, var2, var3);
}
Apart from this, it's somehow strange behaviour to have a derived parameter. Since I could pass in a productCount
of 12 and still set limit
to 6.Dontsu
10/25/2023, 12:20 AM