GarouDan
06/12/2020, 10:57 PMopen source kotlin mpp library
?
maven central
, bintray
, jcenter
, other?Hamza
06/13/2020, 5:54 AMVictor Harlan Lacson
06/13/2020, 6:57 AMDom
06/13/2020, 6:30 PMthis
as a parameter to an interface delegate?
interface A
class B(private val c : C) : A
class C : A by B(this)
produces an error saying that "`this` is not defined in this context". Is there a workaround for this?Samyak Jain
06/14/2020, 2:32 PMmwong
06/15/2020, 11:02 AMsealed class ItemType {
data class Section(name: String) : ItemType() {
override fun areContentsTheSame(other: ItemType.Section) = name == other.name
}
data class Item(value: Long): ItemType() {
override fun areContentsTheSame(other: ItemType.Item) = value == other.value
}
abstract fun areContentsTheSame(other: ItemType): Boolean
}
Ryan
06/15/2020, 12:40 PMRyan
06/15/2020, 12:41 PMAntoine Gagnon
06/15/2020, 2:01 PMfun getString(key: String?, default: String?): String?
The issue is that I’m trying to make it so that the compiler can tell if the default is null or not, and make the return type null or not.
I’ve tried doing this:
fun <T:String?>getString(key: String?, default: T): T
But if the default is value null
, the inffered type becomes Nothing?
instead of String?
Any idea on how to do this properly?Ryan
06/15/2020, 2:49 PMdead.fish
06/15/2020, 3:05 PMCollections.singletonList()
is seen as a MutableList
in Kotlin?ec
06/15/2020, 4:35 PMRyan
06/15/2020, 9:53 PMGarouDan
06/15/2020, 10:32 PMSortedSet<String>
to pure array String[]
in Kotlin?parth
06/15/2020, 10:50 PMclass Foo {
val one : String by someProperty()
val two : String? by someProperty()
}
….and if so, what would be the signature of operator fun getValue(…)
?
I guess I could do val two : String? by someOptionalProperty()
to make the type signature easier, but that feels like I’m giving up, y’know?william
06/16/2020, 1:54 AMimport androidx.lifecycle.MutableLiveData
class ClearableLiveData<T> : MutableLiveData<Clearable<T>>() {
fun clear(t: T) {
super.postValue(Clearable.Clear)
super.postValue(Clearable.Value(t))
}
}
sealed class Clearable<T> {
object Clear: Clearable<Any>()
data class Value<T>(val t: T): Clearable<T>()
}
The first call to super.postValue
gives a type mismatchGarouDan
06/16/2020, 3:19 AMKotlin Common
instead of JVM?
class MyClass<MyGeneric> {
lateinit var myGenericClass: Class<MyGeneric>
fun init() {
myGenericClass =
(javaClass.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<MyGeneric>
}
}
Get the generic type?Patrick
06/16/2020, 7:56 AMCLOVIS
06/16/2020, 8:12 AMspand
06/16/2020, 9:23 AMcontinue
from within an inline function like
for (i in (1..2)) {
run { continue }
}
Should it not be the same as return
?Ryan
06/16/2020, 11:45 AMMaria Khalusova
06/16/2020, 12:16 PMwithCached
to perform arbitrary transformations on a Dataset without it being recalculated, and don’t worry about your Dataset unpersisting at the end.
Kotlin Spark API also allows you to have unnamed tuples that you can call with c()
function that takes a variable number of arguments. You can add these to one another like in Python.
Check out the Quick Start Guide to quickly set up all the needed dependencies using Maven or Gradle: https://github.com/JetBrains/kotlin-spark-api/blob/master/docs/quick-start-guide.md
Check out some code examples to get an idea of what the API looks like: https://github.com/JetBrains/kotlin-spark-api/tree/master/examples/src/main/kotlin/org/jetbrains/spark/api/examples
Try it and share your feedback with us either in #kotlin-spark, or via GitHub issues: https://github.com/JetBrains/kotlin-spark-api/issues.Aaron Stacy
06/16/2020, 4:22 PMthis
for a lambda with a receiver. Here's a code snippet https://pl.kotl.in/GtgL1DMFc . Based on https://kotlinlang.org/docs/reference/this-expressions.html it seems like I should be able to reference the outer this
via a label, so why can't the compiler resolve the @A
reference? Thanks!iex
06/16/2020, 5:47 PMwaitForExpectations(timeout: 5, handler: *nil*)
at the end, and in the callback expectation.fullfill()
to have the test wait for the callbackJoseF
06/17/2020, 9:26 AMrequired
parameters in KotlinDsl
that are validated at compilation time?Mananpoddarm
06/17/2020, 2:26 PMA = (char *) malloc(sizeof(char) * 6);
Hi everyone, could someone help me with what is the alternative of malloc in kotlin? I would like to convert above in kotlinAnaniya
06/17/2020, 4:39 PMvaskir
06/17/2020, 4:50 PMBrendan Weinstein
06/17/2020, 5:18 PMval Strings.empty by lazy { "" }
and using Strings.empty
where ever an empty string is needed in code (eg val a = b ?: Strings.empty
)?streetsofboston
06/17/2020, 7:54 PMd1
like this makes it a proper singleton (type === value) and your error goes away.
object d1 : java.util.Date() { // d1 is of type d1, which is a sub-type of java.util.Data
val test = 5
}
Still, why would a local val allows access to test
but a top/global one not…. not sure 🙂streetsofboston
06/17/2020, 7:54 PMd1
like this makes it a proper singleton (type === value) and your error goes away.
object d1 : java.util.Date() { // d1 is of type d1, which is a sub-type of java.util.Data
val test = 5
}
Still, why would a local val allows access to test
but a top/global one not…. not sure 🙂Zach Klippenstein (he/him) [MOD]
06/17/2020, 9:13 PMclass Test {
public void test() {
new Date() {
public String fooBar() {
return "foo bar";
}
}.fooBar();
}
}
streetsofboston
06/17/2020, 9:39 PM