3

String division using operator overloading in Kotlin, please help me to complete this code. No change can be made in main function. Find common from both string like a=aabcc b=abdec answer=abc (unique common characters)

fun main(args: Array<String>) 
{
      val a:String = readLine()!!

      val b:String = readLine()!!

      val result = a/b

      println(result)
 }
Abdur Rahman
  • 894
  • 1
  • 11
  • 27
divyesh
  • 31
  • 1

1 Answers1

4

Operators can be defined externaly, just like extension functions:

operator fun String.div(other: String): String {
    // Put your implementation here
}

As for the implementation: you should probably do your assignment yourself.

madhead
  • 31,729
  • 16
  • 153
  • 201