Convenience. It's a shorthand that allows you to write a method in
the same place you are going to use it. Especially useful in places
where a method is being used only once, and the method definition is
short. It saves you the effort of declaring and writing
a separate method to the containing class.
Benefits:
Benefits:
- Reduced typing. No need to specify the name of the function, its return type, and its access modifier.
- When reading the code you don't need to look elsewhere for the method's definition.
No comments:
Post a Comment