Gönderi

şartlı operatörle else if yaratmak
sign = ( number < 0 ) ? -1 : (( number == 0 ) ? 0 : 1); If number is less than zero, sign is assigned the value –1; else if number is equal to zero, sign is assigned the value 0; else it is assigned the value 1.The parentheses around the “else” part of the preceding expression are actually unnecessary.This is because the conditional operator associates from right to left, meaning that multiple uses of this operator in a single expression, such as in e1 ? e2 : e3 ? e4 : e5 group from right to left and, therefore, are evaluated as e1 ? e2 : ( e3 ? e4 : e5 )
·
31 görüntüleme
Yorum yapabilmeniz için giriş yapmanız gerekmektedir.