News for hackers. Stuff that matters.
Re:Null Object Pattern in Swift by cballard on Wednesday November 11, 2015 @09:16PM (#10550874)
Just use Optional<T>! This is what it's for!

There's some saying about Java "design patterns" that can just be replaced with closures. There should probably be another for for ADTs.

Re:Null Object Pattern in Swift by arcticbull on Wednesday November 11, 2015 @09:23PM (#10550895)
Agreed completely. The null object with inheritance is particularly difficult to deal with because you're just asking to forget to nerf something dangerous in the superclass leaving you with partially functional objects. Optional<T> is the right way to handle this.