What is the meaning of "static" before "func"?


I saw it before but couldn't find an explanation online, when should I use static and when not to?

  • Nathan Lovato replied

    A static function is a function that can only take arguments and receive a value. It cannot access the object's state. In other words, you cannot use variables defined outside a static function's scope.

    You generally want to use static functions for reusable utilities, or functions that are meant to be passed data and calculate a value from it.