Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
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
fun sum(vararg nums: Int): Int = nums.sum()
fun sum(nums: Array): Int = nums.sum()
fun sum(nums: List): Int = nums.sum()
fun sum(nums: Set): Int = nums.sum()
Int
Unit
Void
Nothing
fun
function
define
declare
A named function
A higher-order function
An anonymous function
A function with a single expression
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()
add(1, 2)
add(x = 1, y = 2)
add(y = 2, x = 1)
x.add(2)
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
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 })
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
It allows the function to be called using infix notation