Big Chungus
07/26/2020, 1:20 PMweber de lima santos
07/26/2020, 7:24 PMWillP
07/27/2020, 4:27 AMuser
07/27/2020, 1:03 PMDavid Alford
07/27/2020, 6:03 PMRobert Jaros
07/27/2020, 7:24 PMw: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar (version 1.3)
/opt/rjaros/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.0-rc/4f17246362f6cbcf924f199a06619a4f77b51335/kotlin-stdlib-common-1.4.0-rc.jar (version 1.4)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
but also compiler errors, which probably are caused by this incompatibility:
Caused by: java.lang.NoSuchMethodError: kotlin.sequences.SequencesKt.flatMapIterable(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
at org.jetbrains.kotlin.resolve.calls.components.CollectionTypeVariableUsagesInfo.getDependentTypeParameters(ResolutionParts.kt:342)
Robert Jaros
07/27/2020, 10:40 PMkotlinx-coroutines-core
1.3.7
which makes my project classpath a mess with both 1.3 a 1.4 Kotlin versions. Is it a bug? Any way to workaround?Jilles van Gurp
07/28/2020, 10:17 AM> Task :publishJvmPublicationToGitHubPackagesRepository FAILED
FAILURE: Build failed with an exception.
16 actionable tasks: 16 executed
* What went wrong:
Execution failed for task ':publishJvmPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'jvm' to repository 'GitHubPackages'
> Could not PUT '<https://github.com/formation-res/FormationSchemaModel/formation-res/FormationSchemaModel-jvm/0.1-SNAPSHOT/maven-metadata.xml>'. Received status code 422 from server: Unprocessable Entity
I'm currently looking at the articact repository in Google cloud as another option. But before I go there, which package repositories actually work properly with the multi platform plugin? I'd be interested in people that have successfully published multiplatform library jars anywhere. This is kind of crucial to me because I want to reuse some code across web, jvm, and ultimately android & ios as well.KayCee
07/28/2020, 10:20 AMtypealias CompletionBlock<T> = UseCase.RequestBlock<T>.() -> Unit
RequestBlock<T> class is like this:
class RequestBlock<T> {
private var onSuccess: ((T) -> Unit)? = null
private var onFail: ((ErrorModel, CallableImp) -> Unit)? = null
private var onFinally: (() -> Unit)? = null
fun onSuccess(block: (T) -> Unit) {
onSuccess = block
}
fun onFail(block: (ErrorModel, CallableImp) -> Unit) {
onFail = block
}
fun onFinally(block: () -> Unit) {
onFinally = block
}
operator fun invoke(result: T) {
onSuccess?.invoke(result)
}
operator fun invoke(error: ErrorModel, apiCallable: CallableImp) {
onFail?.invoke(error, apiCallable)
}
operator fun invoke() {
onFinally?.invoke()
}
}
igor.wojda
07/28/2020, 10:42 AMDo not display the word Kotlin using any different stylization, color, or font from the surrounding text
)
What are your thoughts on using black Kotlin logo?Nir
07/28/2020, 2:38 PMhenrikhorbovyi
07/28/2020, 4:34 PMNir
07/28/2020, 8:14 PMdata class Foo(val bar: List<T>)
Despite the use of both val and List (as opposed to MutableList), it's still pretty easy to mutate data out from underneath Foo. I was curious how many people had felt the need to have some kind of true immutable list type, to prevent this scenario? One pleasant surprise in Kotlin was that I was able to implement something reasonable in just a handful of lines. Even just:
class ImmutableList<T> private constructor(val data: List<T>) : List<T> by data {
constructor(x: Sequence<T>) : this(x.toList())
constructor(x: Iterable<T>) : this(x.toList())
}
operator fun<T> ImmutableList<T>.plus(x: Sequence<T>) = (data.asSequence() + x).toImmutableList()
operator fun<T> ImmutableList<T>.plus(x: Iterable<T>) = (data + x).toImmutableList()
operator fun<T> ImmutableList<T>.plus(x: T) = plus(sequenceOf(x))
fun <T> immutableListOf(vararg elements: T) = elements.asIterable().toImmutableList()
fun <T> Sequence<T>.toImmutableList() = ImmutableList<T>(this)
fun <T> Iterable<T>.toImmutableList() = ImmutableList<T>(this)
Is already pretty usable (thanks mostly to delegation). And now we can go back to our previous example:
data class Foo(val bar: ImmutableList<T>)
This is actually conditionally immutable depending on the T (say it's an Integer or String).
I'm curious if many people are using things similar to this? Or are people just living with the possibility of unexpected mutations in Foo, finding it not too big of a problem?Nir
07/29/2020, 4:47 AMRobert Jaros
07/29/2020, 7:46 AMfrank
07/29/2020, 8:30 AMPhilipp Mayer
07/29/2020, 1:36 PMvar email: String? = "default"
set(value) {
field = setEmail(value)
}
fun setEmail(value: String?): String? {
val emailRegex = Regex("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$")
val isValidEmail = value != null && emailRegex.matches(value)
return if (isValidEmail) value else null
}
The shown field is part of a representation of an old legacy db, which might has a "wrong" email adress in it. Its set by jpa, but I would like to perform the shown operation when the field is set to filter out "wrong" emails.
The function is tested and is returning the correct result.
However, email is always set as "default". What did I do wrong here?
Thanks ahead!Edoardo Luppi
07/29/2020, 2:23 PMNicholas Bilyk
07/29/2020, 3:18 PMNir
07/29/2020, 3:52 PMNir
07/29/2020, 4:43 PMIan
07/29/2020, 4:46 PMbuild.gradle.kts
file: https://gist.github.com/sanity/b89e7d1be5cfd6779e0186f929b45333
But for some reason a number of JVM packages aren't on my classpath, particularly anything in the java.util.concurrent
package, am I missing something from my build file?Nezteb
07/29/2020, 4:55 PMcompareOp(v1: Any, v2: Any, f: (Any, Any) -> Boolean): Boolean
...
compareOp(v1, v2, {x, y -> x < y})
This isn’t quite right though. The “<” on the last line doesn’t compile. Any < Any doesn’t exist.
Since I’m only trying to compare as strings or numbers, it’s possible to write this as:
compareOp(v1: Any, v2: Any, fs: (String, String) -> Boolean, fd: (Double, Double) -> Boolean): Boolean
...
compareOp(v1, v2, {x, y -> x < y}, {x, y -> x < y})
That works, but still doesn’t feel right. {x, y -> x < y} is duplicated. I should be able to pass it in just once.
Its signature is:
<T> fun comparison(x: Comparable<T>, y: T): Boolean
As far as I can tell, it’s not possible to stick this type parameter in the signature of compareOp.
I tried making an interface Comparison<T> with an “operator fun invoke” that has the Comparable<T> signature. That still doesn’t quite work. compareOp has to specify a single explicit value for T.
Has anyone solved this sort of issue?Nicholas Bilyk
07/29/2020, 5:05 PMNir
07/29/2020, 8:09 PMjeggy
07/29/2020, 8:40 PMbbaldino
07/29/2020, 11:10 PMkevin.cianfarini
07/30/2020, 3:29 AMString.toULong
?Nicholas Bilyk
07/30/2020, 2:20 PMReddyTintaya
07/30/2020, 5:09 PMReddyTintaya
07/30/2020, 5:09 PMBig Chungus
07/30/2020, 5:19 PMReddyTintaya
07/30/2020, 5:20 PM