From c11be25ff8820abb37ad69f3ffeadc904b5670ac Mon Sep 17 00:00:00 2001
From: Cedric Beust
@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.