header/impl关键字在kotlin中是什么意思? [英] What does header/impl keyword mean in kotlin?

查看:103
本文介绍了header/impl关键字在kotlin中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚才,当我探索Kotlin github存储库时,我发现了一些有趣的东西:Kotlin现在似乎有一个header关键字.

CollectionsH.kt :

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

 //...

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

是什么意思?是一些公共可用功能还是内部功能来帮助stdlib开发?


似乎有一个impl关键字与标头结合使用.那是什么?

解决方案

更新2:

多平台项目支持已发布.

更新1:

在Kotlin的多平台项目的预览版本中,implheader关键字已由actualexpect替换.

可以在此处或此处找到官方文档 GitHub 永久链接


此视频在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.

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?

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆