kristofdho
02/23/2018, 12:11 PMralf
03/06/2018, 2:39 AM.assertValueAt(2) {
it is ImageChangeEvent.ImageUpdated
&& it.position == 0
&& it.changedFields.contains(CollectImage.IMAGE_MODE)
&& it.image.imageMode == newImageMode
}
The Kotlin Lint plugin complaints about this with Line must not begin with "&&"
. Is this actually true? I couldn’t find anything in the coding conventionscbruegg
03/11/2018, 7:48 PMset(value) = ...
for custom setters on variable is also allowed, I'd say it's no problem. Unit
is just a normal return type and value in Kotlin.Andreas Sinz
04/30/2018, 6:26 PMcatch exception
-> put it in a Result
-> rethrow another/the same exception
, so definitely Option 2Shawn
06/06/2018, 1:53 PMprivate fun String.endpoint() = File(this).name.split("?")[0]
vs
private val String.endpoint
get() = File(this).name.split("?")[0]
Luke
07/19/2018, 5:37 PMlamdba?.invoke()
?gildor
07/27/2018, 1:07 PMelect
08/06/2018, 1:40 PMfatih.yalmanbas
08/16/2018, 8:25 AMБежан Александр
08/28/2018, 10:47 AMenleur
10/08/2018, 2:42 PMval c = if (a !== b)
"1" else
"2"
2:
val c = if (a !== b)
"1"
else
"2"
3:
val c = if (a !== b) "1"
else "2"
4:
val c = if (a !== b) {
"1"
} else {
"2"
}
Shawn
10/08/2018, 2:46 PMval result = if (condition) first
else second
enleur
10/08/2018, 2:49 PMShawn
10/23/2018, 3:40 PM!
is a single, slender character that’s easier to gloss over than not
isHullaballoonatic
10/23/2018, 4:27 PMyole
11/02/2018, 8:36 AMyole
11/02/2018, 8:38 AMHullaballoonatic
11/14/2018, 8:19 PMliminal
11/18/2018, 8:49 PMenum
class, is it better to declare it inside a data class (where it logically belongs) or top-level outside of the class declaration?enleur
11/19/2018, 6:15 PMhudsonb
11/20/2018, 2:22 AMarekolek
11/22/2018, 9:26 AMkenkyee
11/27/2018, 2:16 PMarekolek
11/27/2018, 2:34 PMkenkyee
11/27/2018, 3:02 PMturansky
12/03/2018, 10:37 AMtarek
12/12/2018, 10:09 PMval myFunc: A.() -> Unit = { // this: A
customField = "value"
}
val otherFunc: A.() -> Unit = { // this: A
otherField = "other"
}
I want to have a function that is the combination of both above
I don't know how to write this.ghedeon
12/18/2018, 5:15 PMwith
then realize that the type is nullable and fallback to ?.apply{}
? Relevant question on SO: https://stackoverflow.com/questions/35723226/how-to-use-kotlins-with-expression-for-nullable-typesjames.cruz
12/19/2018, 6:28 AMobject
implementation.
What's the preferred way to get the implementation's instance?
1️⃣ Companion object as the default implementation
interface Foo {
companion object : Foo {
// default implementation goes here
2️⃣ Quasi constructor
interface Foo {
companion object {
operator fun invoke(): Foo = DefaultFooImpl
3️⃣ Top level method
fun defaultFoo(): Foo = DefaultFooImpl
egorand
12/21/2018, 3:19 PM