logoalt Hacker News

pillmillipedestoday at 11:41 AM1 replyview on HN

if a user with/without phone number are equally valid states to be then types won't help you much. I think it's more about writing

  class User{phone: ?PhoneNumber}
over

  class User{phone: ?string}.

Replies

throwwwlltoday at 12:24 PM

To expand and give some notion of good taste:

It's more about writing

    struct User {phone: MaybePhoneNumber} // give or take, it's a monoid
over

    struct User {phone: Option<String>}
show 1 reply