Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Kotlin synthetic properties

I'm trying Vert.x in Kotlin. I have the following piece of code:

val deploymentOptions = DeploymentOptions()
deploymentOptions.setConfig(JsonObject().put("http.port", 8081))

Everything works fine. However, IntelliJ IDEA reports on the second line that I should use "Kotlin synthetic properties".

Any idea how to do that in this case. Also, I'm using Maven.

Solution:

deploymentOptions.config = JsonObject().put("http.port", 8081)

Thanks for the help :)

like image 446
cannot_mutably_borrow Avatar asked Oct 08 '16 18:10

cannot_mutably_borrow


People also ask

What is synthetic property in kotlin?

Synthetic properties to access views were created as a way to eliminate the common boilerplate of findViewById calls. These synthetics are provided by JetBrains in the Kotlin Android Extensions Gradle plugin (not to be confused with Android KTX).

Is findViewById deprecated?

Is findViewById deprecated? findViewById. Recently Android has announced that with Kotlin 1.4. 20, their Android Kotlin Extensions Gradle plugin will be deprecated and will no longer be shipped in the future Kotlin releases.

Is view binding deprecated?

Kotlin Android Extensions is deprecated, which means that using Kotlin synthetics for view binding is no longer supported. If your app uses Kotlin synthetics for view binding, use this guide to migrate to Jetpack view binding.

What is Kotlinx android synthetic?

The Kotlin Android Extensions is a compiler plugin that allows you to access views from your XML directly in activities, fragments and views using what they refer to as synthetic properties. To use it, ensure that the plugin is enabled in your module's build.gradle file: apply plugin: 'kotlin-android-extensions'


1 Answers

Hit alt+enter on that line. IDEA should suggest you a solution. Pick one.

Probably:

deploymentOptions.config = JsonObject().put("http.port", 8081)

like image 185
klimat Avatar answered Nov 15 '22 10:11

klimat