小编cju*_*jiu的帖子

Kotlin:财产制定者的文件

我正在写一个Kotlin图书馆.在其中一个课程中,我有以下内容:

class SessionWrapper {

    /**
     * The time in milliseconds after which the session will expire.
     */
    var expiryTime = DEFAULT_EXPIRY_TIME
        get() {
            mainThreadCheck()
            return field
        }
        set(value) {
            mainThreadCheck()
            field = value
            updateExpiry(value) <<< THIS ONE
        }

    ...
}
Run Code Online (Sandbox Code Playgroud)

但是,如果他们修改了(即调用setter),则updateExpiry(long)有一个对客户端应该是透明的行为.SessionWrapperexpiryTime

现在,对于Kotlin项目,这不会是一个问题,因为我可以将额外的KDoc添加到expiryTime属性本身,并且它不会感觉不合适:

    /**
     * The time in milliseconds after which the session will expire.
     *
     * Updating the expiry time after the session is started does x,
     * the listeners will receive y.
     * …
Run Code Online (Sandbox Code Playgroud)

java javadoc kotlin kdoc

8
推荐指数
1
解决办法
442
查看次数

标签 统计

java ×1

javadoc ×1

kdoc ×1

kotlin ×1