Hi ,
Here I am sharing another topic i.e. Infix Function
Take a look :
So here , we can say that it improves the readability.
I will catch you later , till then Happy Coding :)
Here I am sharing another topic i.e. Infix Function
- Infix functions can be a Member Function or Extension Function
- These functions can have only single parameter
- They have prefix of "infix"
- All infix functions are extension function But all extension function are not Infix
Take a look :
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) var i : Int = 45 var j : Int = 91 var k = i findTheGreaterNum j //calling the infix function println("In I: $i & in J: $j , greater number is : "+ k) } /** * Extension Function */ infix fun Int.findTheGreaterNum(j :Int) : Int { if(this > j) return this else return j }
So here , we can say that it improves the readability.
I will catch you later , till then Happy Coding :)
No comments:
Post a Comment