I am new to Kotlin and was playing around with the data types. I took an Int
type and then tried to cast it as a Double
by saying num as Double
, a call that is valid in java (non syntactically but you get the point). However, this failed, saying that Int cannot be cast to Double. I am assuming this is because it is built off the Integer class rather than the raw int data type. Am I correct, and what is the most efficient way to cast values? There is a .toDouble()
function, but this seems inefficient and unwieldy.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…