愚蠢的问题:假设我在条件语句中分配了一个 var。我不知道条件是否会得到满足,我仍然希望定义 var .. 写这个的正确方法是什么
例子:
NSDecimalNumber *number = [[NSDecimalNumber alloc]init]; // this is pointless right?
if(x == z){
number = [whatevernum1 decimalNumberByMultiplyingBy: whatevernum2];
} else {
number = [whatevernum2 decimalNumberByDividingBy: whatevernum3];
}
// do something with number variable.