![]() ![]() This works for most Kotlin declarations, such as functions, classes, interfaces, enumerations, properties, and annotations. With this mechanism, a common source set defines an expected declaration, and platform source sets must provide the actual declaration that corresponds to the expected declaration. If you're developing a multiplatform application that needs to access platform-specific APIs that implement the required functionality (for example, generating a UUID), use the Kotlin mechanism of expected and actual declarations. We'll do our best to minimize any changes you will have to make. It is almost stable, but migration steps may be required in the future. Here's how you can change its visibility.The expect/ actual feature is in Beta. The constructor is public by default in the example below: For that, you need to explicitly add constructor keyword. base.b, base.c and base.e() are not visibleīy default, the visibility of a constructor is public. a, c, d, and e() of the Base class are visible Note: If visibility modifier is not specified, it is public by default.įun function1() // visible to the Base and the Derived class Not available for packages (used for subclasses) ![]() Visible inside the same module (a set of Kotlin files compiled together) Visible inside the file containing the declaration Recommended reading: Kotlin Packages Modifier You will learn about two more visibility modifiers protected and internal (as well as public and private) in detail.Ī package organizes a set of related functions, properties and classes, objects, and interfaces. In Kotlin Class and Objects article, you learned about visibility modifiers public and private in brief. (You cannot set visibility modifier of getters as they always take the same visibility as that of the property.) Visibility modifiers are keywords that set the visibility (accessibility) of classes, objects, interface, constructors, functions, properties and their setters. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |