FindUserResult() data class NotFound(val name: String) : FindUserResult() } fun findUserByName(name: String): FindUserResult { .... if (ݟ͔ͭͬͨ) return FindUserResult.Found(user) else return FindUserResult.NotFound(name) } val result = findUserByName("bitz") when (result) { is FindUserResult.Found -> println("find ${result.user}") is FindUserResult.NotFound ->println("find ${result.name}") } ϓϥΠϚϦίϯετϥΫλ ͜ΕܧঝͳΜͰ͢Ͷʂ