윤동환
08/16/2023, 8:42 AM@JvmInline
value class Men(val human: Human) {
/** men specific functions */
}
@JvmInline
value class Woman(val human: Human) {
/** women specific functions */
}
The reason why i wrapped human by Men or Women is Human has so lots of properties that i want to devideJakub Syty
08/16/2023, 8:45 AMJakub Syty
08/16/2023, 8:47 AMStephan Schröder
08/16/2023, 12:29 PMsealed class Human(
// comman properties
){
class Man(...): Human(...) {...}
class Woman(....): Human(...) {...}
class Other(....): Human(...) {...}
// common methods
}
If you don't maybe construct a Wrapper hierachy in this way. The main problem in your current approach is that the classes Man and Woman share no common superclass apart from Any (which is to broad). And a function expection Human couldn't be provided with an instance of Man or Woman (even though JavaInline value classes are (mostly) compiled away).