こういうコードを書いた覚えはないだろうか 例えば商品の代金を計算したいとする。その時の計算処理は一般化し、以下のように記述することができる。 fun calcPurchasePrice(price: Int, quantity: Int): Int { if (price < 0 || quantity < 0) { throw IllegalArgumentException("Price and quantity must be positive") } return price * quantity } ですが、このコードは少し回りくどい。なぜかというと、ifに続く実装を見なければ、「こ…