From c11be25ff8820abb37ad69f3ffeadc904b5670ac Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 5 Dec 2015 08:24:14 -0800 Subject: [PATCH] Builder. --- plug-in-development/index.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plug-in-development/index.html b/plug-in-development/index.html index 1843830..8808065 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -302,10 +302,7 @@ class Info(val publish: Boolean)

 @Directive
-public fun myConfig(init: Info.() -> Unit) = Info().apply {
-    init()
-    this
-}
+public fun myConfig(init: Info.() -> Unit) = Info().apply { init() }

The @Directive 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 myConfig function that accepts a closure as an argument. It creates an Info object, calls the init() function on it (which runs all the code inside that closure) and then return that Info object.