header/impl关键字在kotlin中是什么意思? [英] What does header/impl keyword mean in kotlin?
问题描述
刚才,当我探索Kotlin github存储库时,我发现了一些有趣的东西:Kotlin现在似乎有一个header关键字.
open header class ArrayList<E> : MutableList<E> {
//...
header inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
是什么意思?是一些公共可用功能还是内部功能来帮助stdlib开发?
似乎有一个impl
关键字与标头结合使用.那是什么?
更新2:
多平台项目支持已发布.
更新1:
在Kotlin的多平台项目的预览版本中,impl
和header
关键字已由actual
和expect
替换.
在此视频在14:28进行了讨论.
从幻灯片:
基本上,当为跨多个平台(JVM,JS和本机)工作的模块编写接口时,将使用header
.在为特定平台编写实现时,将使用impl
关键字.
Just moments ago when I was exploring the Kotlin github repo, I found something interesting: Kotlin now seems to have a header keyword.
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?
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:
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.
这篇关于header/impl关键字在kotlin中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!