6

Just moments ago when I was exploring the Kotlin github repo, I found something interesting: Kotlin now seems to have a header keyword.

CollectionsH.kt:

 open header class ArrayList<E> : MutableList<E> {

 //...

 header inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>

What does it mean? Is it some public available feature or a internal feature to help stdlib development?


EDIT: There seems to be a impl keyword that work in conjunction with header. What's that?

glee8e
  • 6,180
  • 4
  • 31
  • 51

1 Answers1

6

UPDATE 2:

Multiplatform project support has been released.

UPDATE 1:

The impl and header keywords have been replaced by actual and expect in the preview release of multiplatform projects for Kotlin.

The official documentation can be found here or at this GitHub permalink


It was talked about in this video at 14:28.

From the slides: Slide #14

Basically, header will be used when writing interfaces for modules that work across multiple platforms (JVM, JS, and Native). Theimpl keyword will be used when writing an implementation for a specific platform.

Aro
  • 609
  • 9
  • 15
  • These should be all one need to know about `header` and `impl` keyword`. Thanks for digging that out. – glee8e Jun 28 '17 at 07:07