• +91 9723535972
  • info@interviewmaterial.com

Kotlin Interview Questions and Answers

Question - What is an infix function in Kotlin?

Answer -

An infix function is used to call the function without using any bracket or parenthesis. You need to use the infix keyword to use the infix function.

class Operations {
 var x = 10; 
 infix fun minus(num: Int) {
  this.x = this.x - num
 } 
}
fun main() {
 val opr = Operations()
 opr minus 8
 print(opr.x)
}

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners