if (self = [super init]) vs. if ((self = [super init]))

后端 未结 3 437
时光取名叫无心
时光取名叫无心 2020-12-09 08:59

Was just doing a code review and started to wonder:

I thought if (self = [super init]) checks whether assigning return value of [super init]

3条回答
  •  盖世英雄少女心
    2020-12-09 09:44

    "An assignment expression has the value of the left operand after the assignment" (C99), so either way it has the value of variable, as you put it. The extra parentheses make no difference (except possibly for warnings).

提交回复
热议问题