Viktor Qvarfordt
08/03/2019, 12:20 PMinline class
but it does not provide init
so I have nowhere to place an assert
. Any ideas?Dominaezzz
08/03/2019, 12:25 PMDominaezzz
08/03/2019, 12:25 PMinternal
.Viktor Qvarfordt
08/03/2019, 12:45 PMDominaezzz
08/03/2019, 12:46 PMViktor Qvarfordt
08/03/2019, 12:47 PMinline class
(for performance and so that my type Score can be used directly without doing Score.score)
class Score(val score: Double) {
init {
if (score < 0 || score > 1) throw IllegalArgumentException("Score must be in range [0, 1].")
}
}
Dominaezzz
08/03/2019, 12:49 PMinline class Score internal constructor(val score: Double)
fun createScore(score: Doublue): Score {
if (score < 0 || score > 1) throw IllegalArgumentException("Score must be in range [0, 1].")
return Score(score)
}
Viktor Qvarfordt
08/03/2019, 12:50 PMScore
to be initialized incorrectly by not using the createScore
wrapperSiebelsTim
08/03/2019, 12:53 PMViktor Qvarfordt
08/03/2019, 12:54 PMPrimary constructor of inline class must be public
.Dominaezzz
08/03/2019, 12:55 PM@PublishedApi
attribute, or whatever it's called.karelpeeters
08/03/2019, 4:34 PMkarelpeeters
08/03/2019, 4:35 PMkarelpeeters
08/03/2019, 4:35 PMDominaezzz
08/03/2019, 4:36 PMDominaezzz
08/03/2019, 4:37 PMResult
inline class for instance.Dominaezzz
08/03/2019, 4:41 PMkarelpeeters
08/05/2019, 7:07 AM@PublishedApi
to use an internal
property in public inline
functions.karelpeeters
08/05/2019, 7:08 AMResult
is weird in a couple of ways.