Questions tagged [kotlin]
Kotlin is a cross-platform, statically typed, general-purpose high-level programming language with type inference. This tag is often used alongside additional tags for the different targets (JVM, JavaScript, native, etc.) and libraries/frameworks (Android, Spring, etc.) used by Kotlin developers, if the question relates specifically to those topics.
kotlin
96,540
questions
5
votes
1
answer
2k
views
Kotlin and Android Databinding
Updated 21.06.2015
I wanna try kotlin and android databinding in a same project. But when I add to kotlin-gradle-plugin dependency I cannot build even an empty project anymore with error:
cannot ...
2
votes
1
answer
2k
views
Kotlin JS - Accessing HTML DOM properties
What is the canonical way to access HTML DOM properties in Kotlin. I don't see some of the dom properties like offsetHeight & offsetWidth exposed in the Element
var e : Element? = document....
1
vote
2
answers
2k
views
Kotlin JS - string to number conversion?
How to do String to number conversion in Kotlin JS app. I am Using the following code and having some trouble converting from the HTMLInputElement value to double.
fun c2f(self: Any) {
console.log(...
1
vote
2
answers
261
views
Where is the old Kotlin specification hosted?
I am trying to find the old version of Kotlin site (jetbrains.com/kotlin) with the old documentation. I saw it somewhere on the internet not so long ago, but now I can not find it.
Please, point me ...
3
votes
2
answers
1k
views
SugarORM + Kotlin: Unresovled reference "listAll"
I am trying to use the gorgeous Kotlin and SugarORM in combination for Android development and have my models set up like this:
import com.orm.SugarRecord
public class Contact : SugarRecord<...
15
votes
2
answers
7k
views
Partial class delegation in Kotlin
How do I partial delegate methods/fields in Kotlin?
To be specific: here I am trying to inherit class User from interface TraitA and implement field marked: Boolean in the wrapper StateA. That would ...
15
votes
2
answers
5k
views
Access property delegate in Kotlin
Kotlin has delegated properties which is a very nice feature. But sometimes get() and set() methods are not enough. Let's say I want to create a Closeable object lazily and to close it later. Here's ...
3
votes
1
answer
2k
views
Kotlin stub/placeholder function for unimplemented code
Scala's Predef has a bunch of shorthand functions including one for unimplemented code, namely ???. Does Kotlin have anything similar rather than having to resort to the longhand
throw Error("Code ...
16
votes
2
answers
7k
views
Use Kotlin extension in android java class
Is it possible to use a kotlin extension in a android java class?
Example:
fun String.getSomething(): String {
return "something"
}
then in Java use it like:
String someString = "blabla";
...
75
votes
12
answers
50k
views
Kotlin 'when' statement vs Java 'switch'
Pattern matching in Kotlin is nice and the fact it does not execute the next pattern match is good in 90% of use cases.
In Android, when database is updated, we use Java switch property to go on next ...
1
vote
0
answers
73
views
Kotlin let analogue which returns the receiver [duplicate]
I was wondering if there's a standard function which behaves similarly to let but returns the receiver itself, not the value calculated by block.
My piece of code with let:
fun rightParts(s: Lexeme) ...
38
votes
10
answers
33k
views
Kotlin - IntelliJ Project Setup
I want to start a new project with Kotlin for the JVM using the IntelliJ IDE, but I can't get a configuration for it to work. I was attempting to follow this tutorial, and after that didn't work (the ...
3
votes
2
answers
1k
views
Using multiple JVM languages in the same project
I'd like to use Kotlin & Scala together in projects, and maybe some other languages, but I've seen no good way of doing it. The only way I thought of was compiling one language and decompiling it ...
71
votes
3
answers
41k
views
Volatile properties in Kotlin?
How does one mark a var in Kotlin volatile?
volatile public var tmpEndedAt: Long? = null
gives me the error:
"unresolved reference: volatile"
87
votes
4
answers
40k
views
Dollar Sign Character in Multiline Strings
What is the cleanest method for adding a $ character in a string literal?
The best solution I've come up with so far is """${"$"}...""", which looks ugly to me.