Skip to content

Commit

Permalink
chore(doc): update Packages to idea theme
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderPrendota committed Jul 11, 2018
1 parent b35c4a8 commit 8b96dc7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pages/docs/reference/packages.md
Expand Up @@ -9,15 +9,16 @@ title: "Packages and Imports"

A source file may start with a package declaration:

<div class="sample" markdown="1" theme="idea" data-highlight-only>
``` kotlin
package foo.bar

fun baz() {}

class Goo {}
fun baz() { ... }
class Goo { ... }

// ...
```
</div>

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`.
Expand Down Expand Up @@ -53,22 +54,28 @@ Syntax for imports is described in the [grammar](grammar.html#import).

We can import either a single name, e.g.

<div class="sample" markdown="1" theme="idea" data-highlight-only>
``` kotlin
import foo.Bar // Bar is now accessible without qualification
```
</div>

or all the accessible contents of a scope (package, class, object etc):

<div class="sample" markdown="1" theme="idea" data-highlight-only>
``` kotlin
import foo.* // everything in 'foo' becomes accessible
```
</div>

If there is a name clash, we can disambiguate by using *as*{: .keyword } keyword to locally rename the clashing entity:

<div class="sample" markdown="1" theme="idea" data-highlight-only>
``` kotlin
import foo.Bar // Bar is accessible
import bar.Bar as bBar // bBar stands for 'bar.Bar'
```
</div>

The `import` keyword is not restricted to importing classes; you can also use it to import other declarations:

Expand Down

0 comments on commit 8b96dc7

Please sign in to comment.