Nice short and to the point video. "Nothing" also has a mathematical meaning behind it. A type defines the valid values of a variable, ie a type defines a "set" of (valid) values: - A sub-type is a sub-set of those values (eg in Java, Integer is a sub-set of Number. S < T - An *empty* set is a sub-set of every other set you can imagine (X is not empty). {} < X - The type "Nothing" defines a an *empty* set, since it has no values. Nothing --> {} - This means that "Nothing" is a sub-type of every other type. Nothing < T And that is why you can assign "null" to any nullable type (String?, Int?, Foo?): - The value "null" has the type "Nothing?" and "null" is its only value. Nothing? --> {} | "null" = { "null" } - Because "Nothing" is a sub-type of every other type, "Nothing?" is a sub-type of every other nullable type. { } | null < X | null --> Nothing? < X? - And since "null" is a "Nothing?", you can assign "null" to every nullable variable.
Please make video on jetpack compose for supabase database with login sign up with email and password and verify email using otp and reset password using otp please make video on this topic
Nice content, thanks for posting! Quick question: if I decide to specify a type context for T, it won't be possible to stick to Nothing in the Error data class because of type intersection. How would you tackle this?
@@HumanBeingSpawn if videos would support dynamic theme that would be next level, cause i like to have light mode on daytime at work and dark mode on nighttime when working on personal projects
If httpResponse() returns `OurResult.Error` then the `.valueOr { return }` will enter the this `alternative` function. However the `{ return }` will return from the `main` function as `valueOr` is marked as `inline`, therefore it can never happen that `nothing.length` would be evaluated. The code is similar to ``` fun main() { val httpResponse = when(val result = httpRequest()) { OurResult.Success -> result.value OurResult.Error -> return / *
This is the most brilliant non-clickbait clickbait I've ever seen on UA-cam
😂😂😂😂😂😂😂
Had me in the first half.
Nice short and to the point video.
"Nothing" also has a mathematical meaning behind it.
A type defines the valid values of a variable, ie a type defines a "set" of (valid) values:
- A sub-type is a sub-set of those values (eg in Java, Integer is a sub-set of Number.
S < T
- An *empty* set is a sub-set of every other set you can imagine (X is not empty).
{} < X
- The type "Nothing" defines a an *empty* set, since it has no values.
Nothing --> {}
- This means that "Nothing" is a sub-type of every other type.
Nothing < T
And that is why you can assign "null" to any nullable type (String?, Int?, Foo?):
- The value "null" has the type "Nothing?" and "null" is its only value.
Nothing? --> {} | "null" = { "null" }
- Because "Nothing" is a sub-type of every other type, "Nothing?" is a sub-type of every other nullable type.
{ } | null < X | null --> Nothing? < X?
- And since "null" is a "Nothing?", you can assign "null" to every nullable variable.
Recently made a PR which I named "This fixes Nothing". Couldn't stop myself haha
Is Nothing in fact Everything?
@@tajapan To be or not to be, that's the question.
As a student of philosophy. to say there is a 'nothing' type is absolutely terrifying.
As a programmer, this is cool.
tbh its equal to `never` type in typescript
once a fan of Either, always a fan of Either :P
Please make video on jetpack compose for supabase database with login sign up with email and password and verify email using otp and reset password using otp please make video on this topic
Thank you so much for this!
Just wow!!!
Nice content, thanks for posting! Quick question: if I decide to specify a type context for T, it won't be possible to stick to Nothing in the Error data class because of type intersection. How would you tackle this?
You got me!
I think you solved the Halting Problem :P
Please use dark mode. This really hurts
As always amazing video, crisp clear explanation
get out of your cave, caveman
@@HumanBeingSpawn if videos would support dynamic theme that would be next level, cause i like to have light mode on daytime at work and dark mode on nighttime when working on personal projects
hh a funny title 🃏🃏
LOL, was expecting to see a diffrent video
But wait, what would `httpResponse.length` print if `httpResponse()` returned an `OurResult.Error`? What is the value of nothing.length?
If httpResponse() returns `OurResult.Error` then the `.valueOr { return }` will enter the this `alternative` function.
However the `{ return }` will return from the `main` function as `valueOr` is marked as `inline`, therefore it can never happen that `nothing.length` would be evaluated.
The code is similar to
```
fun main() {
val httpResponse = when(val result = httpRequest()) {
OurResult.Success -> result.value
OurResult.Error -> return / *