Questions tagged as 'kotlin'

1
answer

How can I "delay" the initialization of a property?

There are situations when initializing the property can not be made in the declaration, its value is only known later. An example of this is that in Android, references to views of a layout can only be obtained after the setContentView...
asked by 08.08.2017 / 16:24
4
answers

Equivalent to the conditional or ternary operator in Kotlin

Below I'm logging into the Android Studio in JAVA a short phrase using conditional or ternary operator ( ?) in . See: Log.wtf(GOT, (valirianSteel == 0 && glassOfDragon==0) ? "Run!" : "Run too!"); What would be equivalent to the...
asked by 10.08.2017 / 17:05
3
answers

What is a Label for Kotlin?

In an example of loops in Kotlin documentation , we have some code with following excerpt: loop@ for (i in 1..100) { for (j in 1..100) { if (...) break@loop } } As I read in the documentation, it seems to be a Label and...
asked by 08.08.2017 / 16:45
2
answers

How to customize the getter in Kotlin?

When we create a variable of type val , in the case of Java, only getter is created in relation to it. Different when a variable of type var is created, in which getter and setter is created. Here is an example:...
asked by 10.08.2017 / 15:43
2
answers

Switch case Kotlin

In Java I use switch in several situations, as in the example below : public class SwitchDemo { public static void main(String[] args) { int month = 8; String monthString; switch (month) { case...
asked by 18.08.2017 / 20:49
2
answers

What is Anko?

Since converting my Android projects to Kotlin, in some research that I have been doing, they quoted several times by Anko Kotlin. What is this guy from Anko? What it is? What is your goal?     
asked by 10.08.2017 / 06:20
2
answers

How to initialize an array in Kotlin?

I need to initialize an array in Kotlin but I do not know how to do it, in Java I did so: int numeros[] = new int[] {0,1,3,4,5,6,7,8,9};     
asked by 19.04.2018 / 21:58
1
answer

Generate an APK on a server

I was thinking of an architecture that would work as follows. The user would have a series of parameters to populate and automatically generate code there click in a Buttom, be it in web or mobile would generate an apk application with t...
asked by 10.02.2018 / 12:03
1
answer

Preceded fold return

Kotlin allows returns for previously declared tags , including implicit tags. Documentation example: fun foo() { ints.forEach { if (it == 0) return@forEach print(it) } } In this spirit, I would like to make a lambda expressi...
asked by 01.01.2016 / 15:58
3
answers

In a data class can you have properties other than those generated automatically?

Kotlin allows you to simplify the creation of what we call POJO in Java: data class Person(val firstName: String, val lastName: String) We get a class with the getter for all variables declared in the constructor as well as the methods...
asked by 11.08.2017 / 20:00