amadeu01
01/21/2019, 7:58 PMCoroutineScheduler
uses require
that uses contract
which is experimentalHauke Radtki
01/21/2019, 9:18 PMval cb ={ event: SomeEventType ->
// Do stuff on event
callbackList.remove( /* How to obtain reference to self*/)
}
callbackList.add(cb)
// Do stuff that will trigger cb in the list to be called
Think of a list of one-time callbacks.pniederw
01/22/2019, 1:16 AMursus
01/22/2019, 6:24 AMnkiesel
01/22/2019, 8:36 AMval b = when(val computed = f()) { computed > 0 -> computed + 1 ; else -> computed - 1 }
but this produces a syntax error. Is the only way really to use val computed = f(); val b = when { computed > 0 -> computed + 1 ; else -> computed - 1 }
(with leaking of computed
outside of the when
scope)?pniederw
01/22/2019, 11:03 AMkotlin-stdlib
in its API?amadeu01
01/22/2019, 1:02 PMmyObj?.let { myOtherObj.property = it }
myObj?.let(myOtherObj.property::set)
I was wondering. I just want to set a variable to other object property if my variable is not null. So, could a do something like above .let(myOtherObj.property::set)
?LeoColman
01/22/2019, 1:11 PMmyOtherObj::property::set
, if I'm not mistakenLeoColman
01/22/2019, 1:16 PMamadeu01
01/22/2019, 2:21 PMbram93
01/22/2019, 2:31 PMarild
01/22/2019, 4:39 PMLeoColman
01/22/2019, 4:47 PMBence Zsigmond Nagy
01/22/2019, 7:59 PMstruct
in C#, Swift or even plain-old C)? I see there are a lot of similarities between the two concepts (let's say one is struct
in Swift): they can implement interfaces/protocols, can have properties, methods, and both are allocated on the stack without any memory overhead (please correct me if I'm wrong). What are the differences other than Inline classes can only have one underlying primitive type?nikospamp
01/22/2019, 9:48 PMMutableLiveData<LiveDataRetrofitWrapper> reminders = mRepository.getImportantRemindersByTimestamp(token, timestamp);
And the getImportantRemindersByTimestamp returns this:
val data = MutableLiveData<LiveDataRetrofitWrapper<*>>()
return data
I can understand the error, but I have no idea how to fix it. Thanks!Dalinar
01/23/2019, 5:43 AMDalinar
01/23/2019, 8:29 AMx as String
essentially the same thing as doing (x as String?)!!
?Dalinar
01/23/2019, 9:26 AM()
after the classname is not required...
2. however if you have secondary constructors then it is now required
3. and now you might also want to make that constructor privatemaxmello
01/23/2019, 9:56 AMwhen
. I have a field that holds an enum value and in another place, I have an (exhaustive) when given that field. So the parameter of the when
was of type T
. Then, I changed the field to be instead a LiveData<T>
. A lot of places in my source threw errors and I fixed them by calling .value
on the field. But the when
did not threw an error (as the when does not return anything, the fact that is is no longer exhausive is not an error). But why can I even write:
when(status /* type = LiveData<T>*/) {
T.FIRST_VALUE -> { ... }
T.SECOND_VALUE -> { ... }
T.THIRD_VALUE -> { ... }
as status can never be any of these types? When I try the same structure with a String as parameter, it throws an error (incompatible types).jasondlee
01/23/2019, 2:50 PMmarlonn
01/23/2019, 3:11 PMIcaro Temponi
01/23/2019, 3:43 PMamadeu01
01/23/2019, 4:31 PMlist
like data classes
and then change one of its elements? Something like
var list = List<MyObj>
list = list.copy(element = myObj(), index = 3)
jw
01/23/2019, 4:34 PMAndrew Gazelka
01/23/2019, 5:50 PMthis(...)
. However, sometimes it requires a bit of code to transform parameters to ...
. Should I...
1) have a separate function which acts as a static constructor
2) have the constructor of the class reference a functionuser
01/23/2019, 7:18 PMuser
01/23/2019, 7:53 PMxenoterracide
01/23/2019, 7:54 PMtateisu
01/23/2019, 8:08 PMxenoterracide
01/23/2019, 8:19 PMclass PhgEdsClient : Consumer<EngDataStructure> {
val mqttClient: MqttClient
constructor( serverUri : String ) {
mqttClient = {MqttClient(serverUri, PhgEdsClient::class.simpleName, MemoryPersistence())}()
}
constructor( val mqttClient: MqttClient)
other variation, that doesn’t compile
class PhgEdsClient( val mqttClient: MqttClient ) : Consumer<EngDataStructure> {
constructor( serverUri : String ) {
this(MqttClient(serverUri, PhgEdsClient::class.simpleName, MemoryPersistence()))
}
xenoterracide
01/23/2019, 8:19 PMclass PhgEdsClient : Consumer<EngDataStructure> {
val mqttClient: MqttClient
constructor( serverUri : String ) {
mqttClient = {MqttClient(serverUri, PhgEdsClient::class.simpleName, MemoryPersistence())}()
}
constructor( val mqttClient: MqttClient)
other variation, that doesn’t compile
class PhgEdsClient( val mqttClient: MqttClient ) : Consumer<EngDataStructure> {
constructor( serverUri : String ) {
this(MqttClient(serverUri, PhgEdsClient::class.simpleName, MemoryPersistence()))
}
stephan_marshay
01/23/2019, 8:25 PMSecondary Constructors