Pretty output

Report a typo

Suppose you have an array of comments, commentsData. Each comment stores in the Comment data class:

data class Comment(val id: Int, val body: String, val author: String)

Write a printComments() function that will print each element of the array on a separate line in the format: “Author: AUTHOR; Text: BODY"

For example, if you have an array with two elements: Comment(1, "Test", "Admin") and Comment(2, "Heey", "ActiveUser"), this function will output the following:

Author: Admin; Text: Test
Author: ActiveUser; Text: Heey
Write a program in Kotlin
data class Comment(val id: Int, val body: String, val author: String)

fun printComments(commentsData: MutableList<Comment>){
// write you code here
}
___

Create a free account to access the full topic