tomtau
05/23/2018, 9:52 AMGarouDan
05/23/2018, 1:04 PMval (request, response, result) = await "<http://httpbin.org/get>".httpGet().responseString()
instead of
val (request, response, result) = "<http://httpbin.org/get>".httpGet().responseString() // without await and thread blocking
GarouDan
05/23/2018, 1:29 PMfrellan
05/23/2018, 6:15 PMfrellan
05/23/2018, 6:18 PMTrent Telfer
05/23/2018, 7:47 PMwarriorprincess
05/24/2018, 5:12 AMdiesieben07
05/24/2018, 9:34 AMval myList = listOf(1)
val myNewList = myList + 2 // [1, 2]
diesieben07
05/24/2018, 11:34 AMzmarkan
05/24/2018, 2:16 PMAlowaniak
05/24/2018, 2:32 PMclass A { val x = X(); fun foo(some: Bar) = x::anotherFooAlsoAcceptingOneBar; }
karelpeeters
05/24/2018, 6:57 PMkarelpeeters
05/24/2018, 7:01 PMj - i + 1
?Nicolas Chaduc
05/25/2018, 7:51 AMif let valueCatchNotNull = valueCanBeNull {
} else {
}
we can catch value not null with ?.let
but can’t use elsekarelpeeters
05/25/2018, 7:54 AMval copy = value
if (copy != null) {} else {}
Nicolas Chaduc
05/25/2018, 8:18 AMfun ifLet(value: Any?, code: ((Any) -> Unit)): Boolean {
value?.let {
code.invoke(it)
return true
}
return false
}
fun Boolean.elseLet(code: () -> Unit) {
if (!this) {
code.invoke()
}
}
for use :
ifLet(myMutableValue, {
System.out.println("Call of ifLet Code myInt value = $it")
}).elseLet {
System.out.println("Call of elseLet Code")
}
?brabo-hi
05/25/2018, 10:18 AMadjorno
05/25/2018, 11:43 AMbrabo-hi
05/25/2018, 11:58 AMjackjill
05/25/2018, 1:31 PMorangy
05/25/2018, 1:41 PMPaul Woitaschek
05/25/2018, 1:41 PMPaul Woitaschek
05/25/2018, 1:51 PMPaul Woitaschek
05/25/2018, 1:54 PMreadEnumNullable
robstoll
05/25/2018, 2:15 PMval dowNotNull: DayOfWeek = parcel.readEnum<DayOfWeek>()
if readInt() returns 0? I think you need two implementations anywaydiesieben07
05/25/2018, 3:16 PMthing as Int?
shows "useless cast"diesieben07
05/25/2018, 3:17 PMsamir
05/25/2018, 3:17 PMinterface SomeInterface
enum class SomeEnum: SomeInterface { ValueA, ValueB }
fun someFun(array: Array<SomeInterface>) {}
fun calls() {
val val1 = arrayOf<SomeInterface>(SomeEnum.ValueA, SomeEnum.ValueB) // Array<SomeInterface>
val val2 = arrayOf(SomeEnum.ValueA, SomeEnum.ValueB) // Array<SomeEnum>
val val3 = SomeEnum.values() // Array<SomeEnum>
val val4 = SomeEnum.values() as Array<SomeInterface> // Array<SomeInterface>
someFun(arrayOf(SomeEnum.ValueA, SomeEnum.ValueB)) // Works
someFun(SomeEnum.values()) // Compiler error
someFun(val1) // Works
someFun(val2) // Compiler error
someFun(val3) // Compiler error
someFun(val4) // Works
}
tschuchort
05/25/2018, 5:55 PMlucasqueiroz
05/26/2018, 3:32 AMlucasqueiroz
05/26/2018, 3:32 AMShawn
05/26/2018, 3:34 AMChannels
in the left sidebar, as well as the Common Channels section of the Kotlin Slack Code of Conduct (which you agreed to when making an account)lucasqueiroz
05/26/2018, 3:36 AMShawn
05/26/2018, 3:36 AMtipsy
05/26/2018, 7:04 AM