Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,939 questions

51,876 answers

573 users

How to use if else block as expression in Kotlin

2 Answers

0 votes
fun main(args: Array<String>) {
    var a = 87
    var b = 99
    
    val max = if (a > b) {
         a
    }
     else {
             b
    }
    
    println(max)
}
 
 
 
/*
run:
 
99

*/

 



answered Sep 27, 2020 by avibootz
0 votes
fun main(args: Array<String>) {
    var a = 95
    var b = 87
    
    val max = if (a > b) a else  b
    
    println(max)
}
 
 
 
/*
run:
 
95

*/

 



answered Sep 27, 2020 by avibootz

Related questions

2 answers 219 views
219 views asked Sep 27, 2020 by avibootz
2 answers 109 views
109 views asked May 3, 2023 by avibootz
1 answer 132 views
1 answer 75 views
4 answers 348 views
...