Make the following code work using one of the two discussed solutions.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming usage
Destructuring declarations
Fix a bug
Report a typo
Write a program in Kotlin
class Article(val name: String, val pages: Int, val author: String)
fun getArticleByName(articles: MutableList<Article>, name: String): Article? {
var index = -1
for ((title, pages, author) in articles) {
index += 1
if (title == name) return articles[index]
}
return null
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.