开发者

Assign smaller number to variable in 1 line

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜