Examveda

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")
}

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


This Question Belongs to Computer Science >> Kotlin Program

Join The Discussion

Related Questions on Kotlin Program

What is Kotlin?

A. A new version of Java.

B. A JavaScript framework.

C. A statically-typed programming language for the JVM, Android, and browser.

D. A database management system.