I am beginner in kotlin (in coding in general) and am trying to get the following sentence: "The 6 sided [randomColor] dice rolled [randomNumber]". Basically the only part I cannot get correctly is the color, I get "kotlin.Unit" instead. The code I am using is below. Many thanks in advance for your help!
fun main() {
val myFirstDice = Dice(6)
println ("The ${myFirstDice.numSides} sided ${randomColor()} dice rolled ${myFirstDice.roll()}")
}
class Dice(val numSides: Int){
fun roll(): Int{
return (1..numSides).random()
}
}
fun randomColor() {
val list = listOf("black", "yellow", "green")
val randomColor = list.shuffled().find { true }
}