Skip to content

Commit

Permalink
update: new idiom - instantiate abstract class (JetBrains#2004)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoltauFintel authored Jan 12, 2021
1 parent 0b59f73 commit 780dd0e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pages/docs/reference/idioms.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,29 @@ object Resource {
```
</div>

### Instantiate abstract class

<div class="sample" markdown="1" theme="idea" data-highlight-only>
```kotlin
abstract class AnAbstractClass {
abstract fun doSomething()
abstract fun sleep()
}

fun main() {
val myObject = object : AnAbstractClass() {
override fun doSomething() {
// ...
}

override fun sleep() { // ...
}
}
myObject.doSomething()
}
```
</div>

### If not null shorthand

<div class="sample" markdown="1" theme="idea" data-highlight-only>
Expand Down

0 comments on commit 780dd0e

Please sign in to comment.