Capitalise every word in String with extension function

Since you know capitalize() all you need is to split the string with space as a delimeter to extract each word and apply capitalize() to each word. Then rejoin all the words. fun String.capitalizeWords(): String = split(” “).map { it.capitalize() }.joinToString(” “) use it: val s = “the quick brown fox” println(s.capitalizeWords()) will print: The … Read more

Kotlin Extension Functions Databinding

You have to import CityKt firstly into xml <import type=”my.package.domain.country.model.CityKt” /> int the data section then you can use it like this <TextView android:id=”@+id/city” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@{CityKt.streetName(city)}” /> If you review CityKt you will see that there is static Java method with City as first argument

Accessing Kotlin extension functions from Java

All Kotlin functions declared in a file will be compiled by default to static methods in a class within the same package and with a name derived from the Kotlin source file (First letter capitalized and “.kt” extension replaced with the “Kt” suffix). Methods generated for extension functions will have an additional first parameter with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)