robstoll
04/06/2018, 12:55 PMShawn
04/06/2018, 1:04 PMprivate val _list: MutableList<T>
val list: List<T> = _list
Jeevan
04/06/2018, 2:34 PMjw
04/06/2018, 3:13 PMShawn
04/06/2018, 3:54 PMandreworobator
04/06/2018, 6:42 PMfun bindView(
position: Int,
view: ListItemView // Interface
) = when (ViewTypeEnum.values()[position]) {
ENUM1 -> bindViewType1(view as ViewType1)
ENUM2 -> bindViewType2(view as ViewType2)
}
andreworobator
04/06/2018, 6:58 PMmakarezp
04/06/2018, 8:04 PMmuralimohan962
04/07/2018, 6:41 AMbarteks2x
04/08/2018, 7:14 PMclass LazyToString(val obj: () -> Any) {
override fun toString(): String {
return obj().toString()
}
}
thing = LazyToString { doThing() }
pakoito
04/08/2018, 7:55 PM@parameter
refer to the type the extension is in?gildor
04/09/2018, 2:48 AMpike
04/09/2018, 4:24 AMdiesieben07
04/09/2018, 8:22 AMmzgreen
04/09/2018, 8:22 AMlouiscad
04/09/2018, 9:05 AMjakubgruber
04/09/2018, 9:25 AM@JvmField
and const
? Is property exposed to Java as a static if const
is used? Android Studio recommended that to me, so just asking 🙂marstran
04/09/2018, 10:36 AMcopy
function only copies the constructor parameters. You should do this: data class Person(val name: String = "Tristan", val age: Int = 1)
fun main(args: Array<String>) {
val person = Person()
val personCloned = person.copy(age = 3)
println(personCloned.age)
}
adams2
04/09/2018, 2:06 PMadams2
04/09/2018, 2:06 PMJacks0n23
04/09/2018, 2:13 PMkarelpeeters
04/09/2018, 7:27 PMmakarezp
04/09/2018, 7:47 PMHemanth
04/10/2018, 7:02 AMTarun
04/10/2018, 9:17 AMcompanion object
, than those variable are treated as static in Java
But when I try to access those variable in a java project, which is using library, It is like :
MyClass.Companion.abcVariable
I searched and found I had to append @JvmStatic in front of variable so that java can access it directly like :
MyClass.abcVariable
This works for classes
but for interfaces
it requires a min API level of 24 and my Min API level is 21
Is there any other way to directly access companion object variables for interface
in API projects supporting min API level less than 24 like :
MyClass.abcVariable
Rich Gabrielli
04/10/2018, 8:32 PMpavel
04/10/2018, 9:39 PMby Delegates.notNull()
edwardwongtl
04/11/2018, 3:48 AMfun doSth(action: Mode.() -> Unit)
?
But Mode
contains only functions, no properties.
Although it is completely fine to create instance of Mode
and pass it to action(mode)
, it just doesn't quite make sense for me to create such a instance.louiscad
04/11/2018, 8:13 AMJon
04/11/2018, 9:37 AMrequire
in init
of the class it's in, but the compiler doesn't know that this invariant exists so still requires null-safety checks.Jon
04/11/2018, 9:37 AMrequire
in init
of the class it's in, but the compiler doesn't know that this invariant exists so still requires null-safety checks.karelpeeters
04/11/2018, 9:51 AMAndreas Sinz
04/11/2018, 12:30 PMSiebelsTim
04/11/2018, 1:20 PMgildor
04/11/2018, 3:55 PM