0

What will happen if I change the access modifier of an extension function to private? Does it have any effect? Does it matter?!

private fun String.myExtensionFunction() { // ... }

Mahozad
  • 18,032
  • 13
  • 118
  • 133

1 Answers1

6

The extension method will only be seen in the class/file it is declared in.

Without private the extension method would be public and could be called from the outside.

Frank Neblung
  • 3,047
  • 17
  • 34