All Questions

90
votes
2answers
25914 views

In Kotlin, what is the idiomatic way to deal with nullable values, referencing or converting them

If I have a nullable type Xyz?, I want to reference it or convert it to a non-nullable type Xyz. What is the idiomatic way of doing so in Kotlin? For example, this code is in error: val something...
21
votes
5answers
6370 views

Kotlin and Immutable Collections?

I am learning Kotlin and it is looking likely I may want to use it as my primary language within the next year. However, I keep getting conflicting research that Kotlin does or does not have immutable...
44
votes
2answers
2469 views

Kotlin Bytecode - How to analyze in IntelliJ IDEA?

I'm new to Kotlin and I want to be able to view the compiled bytecode so I can learn more about how it works under the covers. I'm using IntelliJ IDEA 15 but can't find a good way to view the bytecode...
117
votes
3answers
17074 views

What Java 8 Stream.collect equivalents are available in the standard Kotlin library?

In Java 8, there is Stream.collect which allows aggregations on collections. In Kotlin, this does not exist in the same way, other than maybe as a collection of extension functions in the stdlib. Bu...
45
votes
2answers
11697 views

Difference between List and Array types in Kotlin

What is the difference between List and Array types? It seems can make same operations with them (loops, filter expression, etc..), is there any difference in behavior or usage? val names1 = listOf("...
32
votes
2answers
7470 views

Smart cast to 'Type' is impossible, because 'variable' is a mutable property that could have been changed by this time

And the Kotlin newbie asks, "why won't the following code compile?": var left: Node? = null fun show() { if (left != null) { queue.add(left) // ERROR HERE } ...
31
votes
2answers
3456 views

Kotlin's Iterable and Sequence look exactly same. Why are two types required?

Both of these interfaces define only one method public operator fun iterator(): Iterator<T> Documentation says Sequence is meant to be lazy. But isn't Iterable lazy too (unless backed by a Co...
3
votes
1answers
288 views

Cross references in type parameters

For example in Java I could write: public abstract class Element<S extends Snapshot> { ... } public abstract class Snapshot<E extends Element> { ... } And then, somewhere, extend this c...
18
votes
5answers
7026 views

how to run compiled class file in Kotlin?

Jetbrains provides some documentation but I can't find how to run compiled class file of Kotlin. hello.kt: fun main(args : Array<String>) { println("Hello, world!") } compile: $ kotlinc -...
10
votes
3answers
1005 views

What is the best way to declare on UI component in android with Kotlin?

I'm trying to build android application using Kotlin for the first time. I want to declare on some buttons outside the OnCreate method and i can initialize them only Inside this function with findVie...

Previous Next