DEV Community

Discussion on: You don't need null

 
loucyx profile image
Lou Cyx

Why?! If it doesn't have extra_topping then it doesn't have any, and if it has that property then it has extra toppings ... the one defining that "rule" that if something is missing then is invalid is you.

 
martinpham profile image
Martin Pham

If you call a pizzeria to order a pizza, you don’t mention extra toppings. What should they think?
1) You don’t want
2) You forgot to mention

 
loucyx profile image
Lou Cyx

So much mentions of pizza are making me hungry 🤣 ... Answering:

  • If the pizza I ordered comes with some toppings and I didn't said anything, the pizzeria will send their default.
  • If I make clarifications about the toppings, then they'll update the pizza accordingly.

Do you say "keep the default toppings" every time you order?

 
martinpham profile image
Martin Pham • Edited

You didn't answer the question. The question is how would the pizzeria know if:
1) You don't want extra toppings
2) You want but you forgot to ask, or you didn't know that they offer extra toppings

1 should be null, because you stated it explicitly
2 should be undefined, because you haven't decided yet (yes, AKA you haven't defined it yet, that's why it's called undefined)

 
loucyx profile image
Lou Cyx

Did you ever actually bough a pizza? 🤣

  1. Because you didn't asked for any? You don't need to say "I don't want any extra toppings" every time you buy a pizza, you just need to clarify when you want them. Even in Doordash the extra toppings is an optional field, that you can just omit, you don't need to go into it and select "I don't want extra toppings", that's the "default".
  2. That's your problem as a client. You should know that there's an "extra toppings" option, and ask for it if you want them, or omit them if not. If I forget to buy a Pepsi to drink with my pizza and I was thirsty, is not a problem with the pizzeria, is my problem as a client.

Maybe this is not the best analogy for your point about needing 2 different nullish values?

 
martinpham profile image
Martin Pham • Edited

Alright, if you consider it's problem as a client, I have nothing else to say :)

// And you're right, I've never bough a pizza actually..

Some comments have been hidden by the post's author - find out more