如何在 kotlin 注释中写“/*”?

Hap*_*ppy 5 comments nested kotlin

如何/*在跨度代码中写入kotlin 注释?

例如:

/**
 * Defines the route `/route/*`
 */
fun defineRoute() { 
    /* ... */ 
}
Run Code Online (Sandbox Code Playgroud)

现在,根据 Kotlin 的说法,/route/*嵌套注释的开始(所以整个文件都被注释了)。我现在正在使用/route/{*},但这不是一个不错的解决方案。

yuv*_*gin 0

您可以使用 HTML 转义,因此在您的示例中:

/**
 * Defines the route /route/*
 */
fun defineRoute() { 
    /* ... */ 
}
Run Code Online (Sandbox Code Playgroud)

应该达到预期的结果,因为

/作为“/”转义