Getter function #448
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
A function that just returns a value, rather than updating a value (which would be a "setter function"). An example in Solidity might look like:
|
Beta Was this translation helpful? Give feedback.
-
A getter is a function that returns a value. For all public variables, solidity creates this getter function internally so you can call that variable and get its current value. We can also create the getter function for private and internal variables but we need to define ourselves. Like this function functionName () public view returns(<return-type-here>) {
return //anything you can return here.
} |
Beta Was this translation helpful? Give feedback.
@Alex200027fr
A getter is a function that returns a value. For all public variables, solidity creates this getter function internally so you can call that variable and get its current value.
We can also create the getter function for private and internal variables but we need to define ourselves. Like this