Hi everyone.
Welcome back.
In this lecture we will look into the limitations of using VR.
So the number one limitation is that you cannot have var x equal to null.
Because null can be of any type.
You cannot just define null and try to assign that to a var reserved type name.
So this is not allowed.
And another thing is let's say you're going to assign where x equal to ABC.
And then if you try to change a type to something else, let's say if you want to assign x equal to
five, we are trying to change from the string initial info type to another type.
This is also not allowed okay.
And the next thing is that if you go to the top, you cannot use var as an instance variable.
So where in the class properties are not allowed.
So in this case if I try to do this here, the compiler will complain that where is not allowed and
or it cannot even resolve the symbol where.
Okay.
And the.
Another thing is you cannot use where on the function parameters to.
So in this case, let's say if I try to take the string off and try to use where here, this again is
going to give you the same issue cannot resolve symbol where.
So which means where in the function argument is not allowed.
And one more thing which I would like to show you is in the beginning of the lecture I said where is
not a Reserved keywords in this case were equal to Java, so this is still allowed.
So here the compiler is not going to complain.
You cannot use where as a variable.
So these are some of the limitations that you need to be aware of when you are using local variable
type inference.
Using where.
Let me quickly summarize what we have learned so far.
So what I'm going to do, let's go back to the slides and quickly summarize what we have learned as
the limitations of where.
So number one is you cannot have a null value assigned to a where as a type cannot be inferred.
And number two is changing.
The type is not allowed.
Which means if you try to assign a variable to a certain type.
In this case we are assigning where is equal to the hello world, which is a string, and changing that
to a different type is not allowed, and the next thing is where cannot be used as a class property.
Also, you cannot use this at the class level.
So that's one of the reasons why it is named as it is a local variable type inference.
The scope of using where is just local to the functions, and the final one to call out is that where
cannot be used as a function.
Argument two.
So these are the limitations that you need to be aware of anytime you are using where for type inference
or local variable type inference.
This marks the end of this lecture.
Thank you for watching.