Non-null objects, the Null Object pattern, and T.init
bearophile
bearophileHUGS at lycos.com
Sun Jan 19 03:30:00 PST 2014
Jacob Carlborg:
> I think nil (null) works quite nicely in Ruby. nil is a
> singleton instance of the NilClass class. Since it's an object
> you can call methods on it, like to_s, which returns an empty
> string. It works quite well when doing web development with
> Ruby on Rails. If you're trying to render something that's nil
> you'll get nothing, instead of crashing that whole page. Sure,
> there might be a small icon or similar that isn't rendered but
> that's usually a minor detail. If the page is working and main
> content is rendered that's preferable.
Walter is arguing against this solution in D.
While that can be OK for Ruby used for web development, for a
statically typed language meant for safe coding styles, there are
better type-based solution to that problem.
Bye,
bearophile
More information about the Digitalmars-d
mailing list