1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-24 19:47:11 -07:00
This commit is contained in:
Cedric Beust 2015-12-05 08:24:14 -08:00
parent 6c17270b8d
commit c11be25ff8

View file

@ -302,10 +302,7 @@ class Info(val publish: Boolean)
</p>
<pre>
@Directive
public fun myConfig(init: Info.() -> Unit) = Info().apply {
init()
this
}</pre>
public fun myConfig(init: Info.() -> Unit) = Info().apply { init() }</pre>
<p>
The <code>@Directive</code> annotation is not enforced but you should always use it in order to help future tools (e.g. an IDEA plug-in) identify Kobalt directives so they can be treated differently from regular Kotlin functions. The code above defines a <code>myConfig</code> function that accepts a closure as an argument. It creates an <code>Info</code>
object, calls the <code>init()</code> function on it (which runs all the code inside that closure) and then return that <code>Info</code> object.