Luca Nicoletti
02/24/2023, 2:32 PMwhen
statement orders? I’m looking to have all objects
of a sealed class/interface coming first, then the data classes, so my when(s) would look like:
when (a) {
object1 -> {}
object2 -> {}
object3 -> {}
is dc1 -> {}
is dc2 -> {}
}
And not with is
mixed between all the statementsChris Lee
02/24/2023, 2:35 PMLuca Nicoletti
02/24/2023, 2:37 PMmatches its argument against all branches sequentially until some branch condition is satisfied.Meaning that it try from the first until there’s a match, then stops, right?
Chris Lee
02/24/2023, 2:37 PMLuca Nicoletti
02/24/2023, 2:37 PMsealed interface
with 3 objects
and 2 data classes
my instance will be either an object (only one), or a data classLuca Nicoletti
02/24/2023, 2:38 PMChris Lee
02/24/2023, 2:39 PMis C
is checked before is A
. Also, performance may be a consideration - will often organize when expressions knowing that certain conditions are frequently hit (or not).Luca Nicoletti
02/24/2023, 2:40 PMChris Lee
02/24/2023, 2:41 PMLuca Nicoletti
02/24/2023, 2:41 PMBrais Gabin
02/24/2023, 4:45 PMBrais Gabin
02/24/2023, 4:47 PMLuca Nicoletti
02/26/2023, 8:54 AMBrais Gabin
02/26/2023, 1:02 PMwhen
. Copy&paste that rule to your project and edit it until it does what you want.Brais Gabin
02/26/2023, 1:04 PMBrais Gabin
02/26/2023, 1:06 PM