Masonry icon indicating copy to clipboard operation
Masonry copied to clipboard

Adds Nullability

Open fabb opened this issue 8 years ago • 2 comments

No more make? inside blocks.

fabb avatar Oct 31 '16 07:10 fabb

In this case either you change the method to expect a nil return value or you throw an exception there...

Both options may not be viable, but I personally find it very dangerous to have methods disobey their public API contracts. The compiler is right in this case.

Sent from my iPhone

On 31 Oct 2016, at 07:48, fabb [email protected] wrote:

@fabb commented on this pull request.

In Masonry/MASCompositeConstraint.m:

 self = [super init];
  • if (!self) return nil;
  • if (!self) return self; this is a bit awkward, i know, but otherwise the compiler will complain that the method should not return nil due to nullability.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Panajev avatar Oct 31 '16 08:10 Panajev

@Panajev: Actually Apple's default implementation of init looks like this:

- (id)init {
    if (self = [super init]) {
        // code
    }
    return self;
}

This is exactly the same - also returns self when !self.

fabb avatar Oct 31 '16 08:10 fabb