[Python|Java]Ternary operator| a>b?a:b| a if a>b else b

 

JAVA:

import static java.lang.System.out;
public class Ternary
{
    public static void main(String[] args)
    {
        int a = 4, b = 5;
        out.println(++a == b-- ? a : b); //5
    }
}

 

 

Python:

a = 4
b = 5
print(a if a > b else b)

 

posted @ 2020-05-27 09:45  profesor  阅读(188)  评论(0编辑  收藏  举报