From 8b96dc7cd560b9d9856c0e887bbba7f0b4e2aad2 Mon Sep 17 00:00:00 2001 From: Prendota Date: Wed, 11 Jul 2018 11:26:20 +0300 Subject: [PATCH] chore(doc): update Packages to idea theme --- pages/docs/reference/packages.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pages/docs/reference/packages.md b/pages/docs/reference/packages.md index 511828b01da..5be4e29d96d 100644 --- a/pages/docs/reference/packages.md +++ b/pages/docs/reference/packages.md @@ -9,15 +9,16 @@ title: "Packages and Imports" A source file may start with a package declaration: +
``` kotlin package foo.bar -fun baz() {} - -class Goo {} +fun baz() { ... } +class Goo { ... } // ... ``` +
All the contents (such as classes and functions) of the source file are contained by the package declared. So, in the example above, the full name of `baz()` is `foo.bar.baz`, and the full name of `Goo` is `foo.bar.Goo`. @@ -53,22 +54,28 @@ Syntax for imports is described in the [grammar](grammar.html#import). We can import either a single name, e.g. +
``` kotlin import foo.Bar // Bar is now accessible without qualification ``` +
or all the accessible contents of a scope (package, class, object etc): +
``` kotlin import foo.* // everything in 'foo' becomes accessible ``` +
If there is a name clash, we can disambiguate by using *as*{: .keyword } keyword to locally rename the clashing entity: +
``` kotlin import foo.Bar // Bar is accessible import bar.Bar as bBar // bBar stands for 'bar.Bar' ``` +
The `import` keyword is not restricted to importing classes; you can also use it to import other declarations: