+ 2
methods
sorry for the stupid question, but i can't understand methods. pls help
4 Answers
+ 1
They're just sections of code that performs a particular function. If it helps, think of them as "actions." For example, maybe my method is to add two numbers; or it's an action of adding numbers. I would send my numbers to the method, it would perform the action, and then it would return the result to me.
Basically, we use methods because it allows us to write code once and reuse it wherever we see fit. This prevents you from having to constantly rewrite the same code that's used in multiple places. Good rule of thumb: if you're having to rewrite the same block of code, turn it into a method/function.
+ 2
+ 1
thank you so much! so.. they are basically functions?
+ 1
thanks!