TMTOWTDI

2 views
Skip to first unread message

Raoul Duke

unread,
Jul 27, 2022, 5:52:34 PM7/27/22
to pi...@googlegroups.com
as a rule, i don't like it. 

eg 

if (foo != NULL) {
if (foo) {
if (foo != nil) {
if (foo != 0) {
if (!!foo) {
if (foo != undefined) { // har har 

just utter insanity evil bad awful gross nasty ui ux everywhere in programming. 

Mike Austin

unread,
Aug 19, 2022, 10:58:28 PM8/19/22
to PiLuD
Truthyness was a bad idea. if (‘’) { may have seemed convenient in the 90s, but it’s much clearer to see .str.isNullOrEmpty(), etc.
Yes, null is bad, but in flow based typing and intersection types like TypeScript, unions allow the same protection as Option/Maybe without having to create a type for each pattern. Option, Error, Success, Union, etc,

const ref = useRef<HTMLElement | null>(null);

Vs

const ref = useRef<Option<HTMLElememt>>(null);
Reply all
Reply to author
Forward
0 new messages