morcerfdumas
04/20/2019, 7:54 AMelse
branch?Pavlo Liapota
04/20/2019, 8:03 AMsealed class
restricts class hierarchy, i.e. all direct sub-classes are known at compile type. So you can have exhausted when
on class type, while you can create as much objects as you want and all of them can be different.karelpeeters
04/20/2019, 8:03 AMis X
checks are failing?morcerfdumas
04/20/2019, 8:08 AMmorcerfdumas
04/20/2019, 8:10 AMwhen
match them?Pavlo Liapota
04/20/2019, 8:11 AMPavlo Liapota
04/20/2019, 8:16 AMwhen
as expression over all subtypes of sealed class and no branches are executed? Do you get runtime exception?morcerfdumas
04/20/2019, 8:19 AMwhen
doesn’t execute any branch.Pavlo Liapota
04/20/2019, 8:24 AMwhen
as statement, but what will happen if you use it as expression? So something should be returned by a when
from one branch.morcerfdumas
04/20/2019, 8:26 AMmorcerfdumas
04/20/2019, 8:32 AMNoWhenBranchMatchedException
exception here.Pavlo Liapota
04/20/2019, 8:37 AMgildor
04/20/2019, 8:38 AMgildor
04/20/2019, 8:38 AMgildor
04/20/2019, 8:39 AMwhen
morcerfdumas
04/20/2019, 8:41 AMis Type
in when
, but not if I match directlymorcerfdumas
04/20/2019, 8:42 AMParcelable
, it works normally, as expected, but with Serializable
, I have to match by type. Could you explain why this happens?gildor
04/20/2019, 8:42 AMis Type
or implement serialization properlygildor
04/20/2019, 8:42 AMgildor
04/20/2019, 8:44 AMmorcerfdumas
04/20/2019, 8:45 AMgildor
04/20/2019, 8:45 AMgildor
04/20/2019, 8:46 AMgildor
04/20/2019, 8:46 AMPavlo Liapota
04/20/2019, 8:56 AMwhen
over instances if all children are object
.Pavlo Liapota
04/20/2019, 9:00 AMmorcerfdumas
04/20/2019, 9:23 AMgildor
04/20/2019, 11:58 AMgildor
04/20/2019, 12:13 PM