![]() |
VOOZH | about |
this keyword represents an implicit object pointing to the current class object. It refers to the current instance of the class in a method or constructor. The this keyword is mainly used to eliminate the ambiguity between class attributes and parameters with the same name. When the class attributes and the parameter names are the same, this keyword is used to avoid ambiguity by prefixing class attributes with this keyword. this keyword can be used to refer to any member of the current object from within an instance method or a constructor.
Example :
Output:
GFG - Dart THIS Example
The Student ID is : S001
Example :
Output:
The mobile is : M101The this keyword in Dart is a powerful tool that provides clear and unambiguous access to class members. It enhances code readability, enables constructor chaining, and allows method calls within the same instance. By utilizing this, developers can write cleaner and more efficient Dart programs.