LoginSignup
8
9

More than 5 years have passed since last update.

ifステートメントを使わない一行条件処理

Posted at
if (num < 0) num = 0;

これは以下のようにも書くことができる。

num < 0 && (num = 0);

2008年くらいのコード読んでたら上記のような一文が出てきて、なんだこりゃと思って調べた。
直感的に分かりづらいのであんまり好きじゃないなあ。

8
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9