In NixOS types, this is called "NullOr", maybe more clear.
@shubhamjoshi68264 жыл бұрын
thank you Anthony 😊
@brianfontenot99253 жыл бұрын
Optional is really a type that means we have a box and inside the box maybe there is some(value) or none(value). Its a great tool if enforced and completely eliminates the runtime nil/null reference at “compile” time. If incorporated into the language correctly
@goodclover4 жыл бұрын
30:32 I'm sure there's plenty of other thing that you would want to change as well. 😅
@retrom4 жыл бұрын
damn, which dimension is 30minutes into a 4minute video
@goodclover4 жыл бұрын
@@retrom I have no idea what happened there.
@Strider8174 жыл бұрын
I'm one of those people confused by this naming, and your video helped quite a bit in explaining stuff. However, I still don't understand why you can't set an optional function argument to Optional[int], since it seems like Optional means the type could be either Int or None. In your function y is an int when set by default, so why is it not valid to do this?
@anthonywritescode4 жыл бұрын
you can use Optional[int] to annotate a function argument, however it has a different meaning than "this argument is optional" -- it actually means something closer to "this argument is None-able (nullable, but translated to pythonspeak)"
@srkbhayo2 жыл бұрын
thank you . I was sos confused with this keyword
@sadhlife4 жыл бұрын
that new | syntax has already landed in 3.10 apparently
@anthonywritescode4 жыл бұрын
indeed! I've got it in my copy of 3.10a2! >>> int | None int | None
@sadhlife4 жыл бұрын
@@anthonywritescode noice
@shivanshmishra52934 жыл бұрын
Trying to replicate maybe monad I guess.
@anthonywritescode4 жыл бұрын
I mean, it's clear what it is -- just the name is bad :)
@nexovec Жыл бұрын
Even Option[int] would be way better I don't get it...
@realabja13 жыл бұрын
You awesome man🚀
@MElixirDNB Жыл бұрын
OrNone might have been more intuitive. but now we can just use the easier | None syntax.. although lots of work environments are stuck on older python versions so pain ensues