You can add functions to classes, for classes that you did not write, via extension functions.

Instead of a simple function name, use the class, a dot separator, and the desired function name. So, in this snippet, we have String.isValidEmail(), to add an isValidEmail() function to String.

We can then call isValidEmail() on any String, as if isValidEmail() were implemented on String itself.

You can learn more about this in:
Run Edit