I'm just starting to play around and have this lit...
# getting-started
k
I'm just starting to play around and have this little test:
Copy code
class Test (
    val id: UUID
) {
	private constructor(builder: Builder) : this(builder.id)
	companion object {
		inline fun build(id: UUID, block: Builder.() -> Unit)  = Builder(id). apply(block).build()
	}
	class Builder(
		val id: UUID) {
        var text: String? = null
        fun build() = Test(this)
    }
}
but, at
apply
, i'm getting
Unresolved reference: apply
. I am using the Eclipse Kotlin plugin. I know, I should be using IDEA....... one step at a time. 🙂
a
kotlin-stdlib is listed as a dependency?
k
I'll try and find it. Do you have to put this in
pom.xml
or
build.gradle
?
You are a star. added it to the
build.gradle
file as
compileOnly
and it works 🙂 But, do you need this at run time as well?
a
Yes, the stdlib needs to be in the classpath at runtime
k
Got it 👍
k
Although if you're only going to be using
apply
you might be fine without it, since it's
inline
.