‹ BackHN Continuity

Thread

Why isn't mutable a subtype of immutable, or vice versa?

28 points · 56 comments · ibobev

  1. comrade1234 · · focus · HN ↗
    Isn't NSMutableArray a subclass of NSArray in a few languages?
    1. catoc · · focus · HN ↗
      Yes, that’s ObjC, any NSMutableArray is an NSArray (and an NSObject) - classes passed by reference.

      Swift is completely different. Standard arrays are structures, always mutable - value types passed by value

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.