Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
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()
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
Int
Unit
Void
None
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()
sum(1, 2, x = { x, y -> x + y })
sum(1, 2, op = { x, y -> x + y })
sum(1, 2, { x, y -> x + y }, op = true)
sum(x = 1, y = 2) { x, y -> x + y }
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
function
define
declare
fun sum(x: Int, y: Int, op: (Int, Int) -> Int): Int = op(x, y)
fun sum(x: Int, y: Int, op: Int, Int -> Int): Int = op(x, y)
fun sum(x: Int, y: Int, op: Int.(Int) -> Int): Int = x.op(y)
fun sum(x: Int, y: Int, op: (Int) -> Int): Int = op(x + y)
Nothing