Hullaballoonatic
05/16/2019, 2:56 PMComparable
in kotlin when you can just use compareTo
operator?Hullaballoonatic
05/16/2019, 10:23 PMpow
function for Int
? Am I an idiot that I can't see it or don't know why?Florian
05/19/2019, 12:56 PMSmorg
05/20/2019, 1:54 AMwhen (textInputEditText.id) {
R.id.editText_fullName -> {
setState { copy(signUpData = signUpData.copy(fullName = textInputEditText.text.toString())) }
}
R.id.editText_username -> {
setState { copy(signUpData = signUpData.copy(username = textInputEditText.text.toString())) }
}
R.id.editText_email -> {
setState { copy(signUpData = signUpData.copy(email = textInputEditText.text.toString())) }
}
R.id.editText_password -> {
setState { copy(signUpData = signUpData.copy(password = textInputEditText.text.toString())) }
}
}
Hullaballoonatic
05/20/2019, 6:53 PMitnoles
05/20/2019, 6:54 PMdavidasync
05/21/2019, 7:10 AMMarko Mitic
05/21/2019, 2:45 PMEnricCamarero
05/21/2019, 4:33 PMscottiedog45
05/21/2019, 6:44 PMprivate val coroutineContext: CoroutineContext
get() = parentJob + Dispatchers.Default
robnik
05/22/2019, 8:39 AMtasks["foo"]
, tasks.named("foo").get()
, tasks.getByName("foo")
. I guess the first is extra in Kotlin, because the language allows the []
syntax for get
, but is there a difference between the second and third?scottiedog45
05/22/2019, 5:15 PMfun <T : ViewModel, A> singleArgViewModelFactory(constructor: (A) -> T):
(A) -> ViewModelProvider.NewInstanceFactory {
return { arg: A ->
object : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <V : ViewModel> create(modelClass: Class<V>): V {
return constructor(arg) as V
}
}
}
}
Florian
05/25/2019, 9:38 AMPepperbc
05/26/2019, 12:48 PMotakusenpai
05/26/2019, 4:29 PMursus
05/26/2019, 10:20 PMSuspicious equality check: equals() is not implemented in Object
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldList[oldItemPosition] == newList[newItemPosition] <----------
Type of the list items is ChatItem, which is a sealed class
sealed class ChatItem
object ProgressBarItem : ChatItem()
data class ThreadHeaderItem(
val commenterUsername: String,
val commenterRealName: String?,
val commenterImageUrl: String?,
val commentedUsername: String,
val commentedRealName: String?,
val commentedTimestamp: LocalDateTime
) : ChatItem(), ThreadPart
data class AddCommentItem(val message: Message) : ChatItem(), ThreadPart
data class DateItem(val date: LocalDateTime) : ChatItem()
dave08
05/27/2019, 3:02 PMreturn
, so am I returning from the outer function bypassing the use
?
fun doSomething(): Boolean =
resource.use {
if (condition) return false
}
Hullaballoonatic
05/27/2019, 6:21 PMsetA
to also setB
when called, and setB
to also setA
when called, but not infinite loop them? One calls the other but doesn't allow itself to be called again.Ruckus
05/28/2019, 6:37 PMnums.indices.reversed()
ursus
05/29/2019, 2:02 AMAtendra Singh
05/29/2019, 2:05 AMSlackbot
05/29/2019, 4:18 AMjaspersmit
05/29/2019, 9:36 AMval someValueNotNull = somethingReturningNull ?: { sttmt1 stmt2 stmt3 }
poohbar
05/29/2019, 12:35 PMdave08
05/29/2019, 5:39 PMFlorian
05/30/2019, 10:17 AModay
05/30/2019, 4:04 PMHullaballoonatic
05/31/2019, 2:05 AMFlorian
05/31/2019, 11:02 AMnk
05/31/2019, 7:07 PMdata class User(name: String, pass: String, email: String, etc...)
and then an update method which would take a Partial User so that you'd only have to supply a subset of the fields fun update(user: Partial<User>): User {...}
. Should I just create a new type for this? Such as data class PartialUser(name?: String = null, pass?: String = null, email: String = null, etc...)
.nk
05/31/2019, 7:07 PMdata class User(name: String, pass: String, email: String, etc...)
and then an update method which would take a Partial User so that you'd only have to supply a subset of the fields fun update(user: Partial<User>): User {...}
. Should I just create a new type for this? Such as data class PartialUser(name?: String = null, pass?: String = null, email: String = null, etc...)
.serebit
05/31/2019, 7:52 PMnk
05/31/2019, 9:33 PMIan White
05/31/2019, 11:34 PM@PartialDataObjects(["Partial","Create","Update"])
annotation to a data object X and it will create PartialX
, CreateX
, UpdateX
data objects for you. it’s not totally ready for public consumption but i’ve found it super handy for my own projects if you’re interested: https://github.com/stardogventures/stardao/tree/master/stardao-kotlin-partial