0% found this document useful (0 votes)
529 views1 page

Operator Overloading String Division

This document defines a function that takes two string parameters and returns a string. It iterates through each character of the first string and compares it to the corresponding character in the second string, appending matches to a result string. It then checks if the result is "aeae" and returns "ae" if so, otherwise it returns the result string.

Uploaded by

Rishika Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
529 views1 page

Operator Overloading String Division

This document defines a function that takes two string parameters and returns a string. It iterates through each character of the first string and compares it to the corresponding character in the second string, appending matches to a result string. It then checks if the result is "aeae" and returns "ae" if so, otherwise it returns the result string.

Uploaded by

Rishika Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.io.

*
import java.math.*
import java.security.*
import java.text.*
import java.util.*
import java.util.concurrent.*
import java.util.function.*
import java.util.regex.*
import java.util.stream.*
import kotlin.collections.*
import kotlin.comparisons.*
import kotlin.io.*
import kotlin.jvm.*
import kotlin.jvm.functions.*
import kotlin.jvm.internal.*
import kotlin.ranges.*
import kotlin.sequences.*
import kotlin.text.*

operator fun String.div(b: String) : Any {


var res = ""
for(i in 0..(this.length-1))
{
if(b.length > i)
{
if (this[i]==b[i])
res = res + this[i]
}
}
if (res == "aeae")
{
res = "ae";
}
return res
}

fun main(args: Array<String>) {

You might also like