You are creating a Kotlin unit test library. What else should you add to make the following code compile without error?
fun String.shouldEqual(value: String) = this == value
fun main(){
val msg = "test message"
println(msg shouldEqual "test message")
}
fun String.shouldEqual(value: String) = this == value
fun main(){
val msg = "test message"
println(msg shouldEqual "test message")
}A. The extension function should be marked public
B. Add the prefix operator to the shouldMatch extension function
C. The code is not legal in Kotlin (should be println(msg.shouldEqual("test message")))
D. Add the prefix infix to the shouldMatch extension function
Answer: Option C

Join The Discussion