News for hackers. Stuff that matters.
Re:My Opinion on “5” == 5 by tetha on Thursday July 29, 2021 @01:35PM (#27999061)
> Accepting both a numerical user id and a username string is a very valid scenario. However, I believe you should handle that by explicitly trying to parse it as a number, not hoping that automatic coercion will do the right thing. It's just a footgun waiting to go off.

This is why many people recommend questioning the use of basic or naked types. Details vary between the language, but this should be a type UserID with a UserID::from(String) and maybe a UserID::from_symbolic_name(String) and everything but some edge code should work on UserIDs. This makes code easier to read, too.

There are no comments on this comment yet.