Which of the following is the correct way to create a single-line function in Kotlin? - Study24x7
Social learning Network
5 followers study24x7 06 Nov 2024 10:27 AM study24x7 study24x7

Which of the following is the correct way to create a single-line function in Kotlin?

A

fun sum(a: Int, b: Int): Int { return a + b }

B

fun sum(a: Int, b: Int): Int = a + b

C

function sum(a, b) => a + b

D

sum(a, b) -> a + b

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles