Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
It allows the function to be called using infix notation
It specifies that the function should not have a return value
It specifies that the function should not have a receiver parameter
It prevents the use of non-local returns in the function body
fun add(x: Int, y: Int): Int = x + y
fun add(x: Int, y: Int) = x + y
fun add(x: Int, y: Int): Unit = println(x + y)
fun add(x: Int, y: Int): Int => x + y
sum(1, 2) { x, y -> x + y }
sum(1, 2) { x -> x * x }
sum(1, 2, { x, y -> x + y })
sum(1, 2, { x -> x * x })
add(1, 2)
add(x = 1, y = 2)
add(y = 2, x = 1)
x.add(2)
fun
function
define
declare
An argument that is required to be passed to a function
An argument that is passed using a named parameter
An argument that has a default value specified in the function declaration
An argument that is passed using a lambda expression
A function that returns a value
A function that takes another function as a parameter or returns a function as a result
A function that has a variable number of arguments
A function that can be called without any arguments
fun String.capitalize(): String = this.toUpperCase()
fun capitalize(String str): String = str.toUpperCase()
fun String.capitalize(): String = toUpperCase()
fun capitalize(str: String): String = str.toUpperCase()
It allows the function to be called using tail recursion optimization
It allows the function to be called with a variable number of arguments
It allows the function to be called with or without argument names
{ x: Int, y: Int -> x + y } (1, 2)
fun(x: Int, y: Int): Int { return x + y }(1, 2)
fun(x: Int, y: Int) = x + y (1, 2)
{ x, y -> x + y }(1, 2)