Junior — Middle
Mis on sisemise märksõna internal eesmärk programmeerimisel?
sobes.tech AI
Vastus AI-lt
The keyword internal in programming languages (for example, in Kotlin) restricts the scope of an element (class, function, property) to within a single module. This means that such an element is accessible from anywhere inside the module but not accessible from other modules.
This is convenient for encapsulating logic within the module, allowing to hide implementation details from external code, while providing free access within the module.
Example in Kotlin:
internal class Helper {
fun doSomething() { /*...*/ }
}
The Helper class will be visible and accessible only within the current module.