Reputation: 35
I'm trying to go though the Kotlin tutorial from Freecode camp, but have this issue with references.
IntelliJ complained that
fun sayHello(greeting:String, vararg itemsToGreet: String) {
itemsToGreet.forEach { itemToGreet ->
println("$greeting $itemToGreet")
}
}
fun main() {
val interestingThings = listOf("Kotlin", "Programming", "Comic Books")
sayHello(greeting:"Hi", itemsToGreet:"Kotlin", "Programming", "Comic Books")
}
It seems that assigning values to params can be done only by "=", not ":"
Upvotes: 0
Views: 156
Reputation: 6024
"greeting:" is a parameter name hint. Code should look like this:
sayHello("Hi", "Kotlin", "Programming", "Comic Books")
See how hints will be shown automatically.
Upvotes: 1