开发者

Assign smaller number to variable in 1 line

开发者 https://www.devze.com 2023-02-28 13:48 出处:网络
Is there a one-liner for this function? int side = width &l开发者_Python百科t; height ? width : height;

Is there a one-liner for this function?

int side = width &l开发者_Python百科t; height ? width : height;
width = side;
height = side;


width = height = width < height ? width : height;


It is possible:

width = height = width < height ? width : height;

However it's generally not the convention in Java to assign multiple variables on one line.


width = height = Math.min(width, height);


height = width = width < height ? width : height;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号