Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin?

Question:Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin?

1.Val max3 = a.max(b) (Extension Function is One of the idiomatic Solutions in Kotlin)

2.Val max = a > b ? a : b

3.Val max = if (a > b) a else b

4.If (a > b) max = a else max = b


Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!