Function
Function Definition
A function is something that takes in an input, and gives back an output. That seems pretty vague, so I'll provide an example.
- Symbolic
- Java
- JavaScript
- Python
class Multiply {
public static int doubleInt(int input) {
return input * 2;
}
}
function double(input) {
return input * 2;
}
def double(input):
return input * 2
These functions all do the same thing: take in a number, double it, and spit out the doubled result.
As you can see by switching between the tabs, some examples are more strict at ensuring only numbers can be passed as their input, but they all share the same core logic.
Function Call
We've defined what a function is, but what's more important is what a function does. A function call is the term prescribed to actually using a function. A good way to remember: imagine you're calling the function over to do something with a specific value.
- Symbolic
- Java
- JavaScript
- Python
import Multiply;
int result = Multiply.doubleInt(5);
const result = double(5);
result = double(5)