About "Unowned Optional References"

https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html#ID52

let department = Department(name: "Horticulture")
let intro = Course(name: "Survey of Plants", in: department)
let intermediate = Course(name: "Growing Common Herbs", in: department)
let advanced = Course(name: "Caring for Tropical Plants", in: department)
intro.nextCourse = intermediate
intermediate.nextCourse = advanced
department.courses = [intro, intermediate, advanced]

I think nil should be on the "Caring for Tropical Plants"'s nextCourse.

I can only attach one image because I am a new user, but if you go to the weak reference description above, you can see that the image contains nil well.

I wonder why nextCourse is not marked as nil.

FWIW, it is (and should be) `nil.

1 Like

Yes, that's an error in the diagram — thanks for calling it out. I filed a bug (74529003) to track correcting it.

1 Like
Terms of Service

Privacy Policy

Cookie Policy