hmole
09/21/2018, 6:49 AMthing.map(otherThing::method<MyType>)
. I've tried putting brackets everywhere and it doesn't work ☹️vmichalak
09/21/2018, 1:06 PManstaendig
09/23/2018, 5:13 PMjw
09/24/2018, 6:13 PMelect
10/10/2018, 12:46 PMiterator()
on `Enum`s, so that we can write for(e in enum)
? Instead of e in enum.values()
which, I guess, implies an array copy?miha-x64
10/10/2018, 1:49 PMpublic operator fun <T> Array<T>.plus(elements: Array<out T>): Array<T>
have out
receiver variance?
enum class A { A }
enum class B { B }
val sum = A.values() + B.values()
// adding the following function makes the code above work:
private inline operator fun <reified T> Array<out T>.plus(elements: Array<out T>): Array<T> {
val sum = arrayOfNulls<T>(size + elements.size)
System.arraycopy(this, 0, sum, 0, size)
System.arraycopy(elements, 0, sum, size, elements.size)
return sum as Array<T>
}
Hamza
10/10/2018, 2:42 PMghedeon
10/11/2018, 3:04 PMArrays.binarySearch() / IntArray.binarySearch()
that accepts comparator argument? The way it works now, it's possible to perform a binarySearch
in an ascending IntArray
but not in a descending. At the same time, no problems with Array<Int>
.littlelightcz
10/11/2018, 7:10 PMList<Result<T>>
(when using runCatching {}
) which would help be execute some action in case there have been some failures etc.? Since I think this is (or will be) a very common design pattern - similarly as there is a convenience ext. function for List<Deferred<T>>.awaitAll()
.
Recently I was thinking it could be done in the similar fashion as the current .onFailure()
and .onSuccess()
except that the lambda would take List<Throwable>
or List<T>
as an argument (respectively).
Currently what I need to do on such list, is: (1) filter { it.isFailure}
, then (2) I need to check that it is not empty, and not until now (3) I can do something with it. With the above proposal the first 2 steps would be unnecessary and I would be able to define just the part which would execute only if there was at least 1 failed Result. Similarly it could work for successful Result values.karelpeeters
10/31/2018, 6:26 PMIterable<Pair<K, V>>.toMutableMap()
is "missing", that confused me for a second 😒imple_smile:hmole
11/07/2018, 11:09 AMval (a,(b,c)) = 1 to (2 to 3))
?louiscad
11/14/2018, 2:47 PMinline operator fun <R> KProperty0<R>.getValue(thisRef: Any?, property: KProperty<*>): R = get()
inline operator fun <R> KMutableProperty0<R>.setValue(thisRef: Any?, property: KProperty<*>, value: R) {
set(value)
}
Here's a link to an example snippet: https://pl.kotl.in/HyLn42KaQhho
11/15/2018, 11:32 AMlistOf(*yourArray)
?guenther
11/15/2018, 12:56 PMByte
looks like this:
public class Byte private constructor() : Number(), Comparable<Byte> {
companion object {
public const val MIN_VALUE: Byte = -128
public const val MAX_VALUE: Byte = 127
...
Double
on the other hand looks like this:
public class Double private constructor() : Number(), Comparable<Double> {
companion object {
public val MIN_VALUE: Double
public val MAX_VALUE: Double
...
Is there are a particular reason, why the properties in Double
are not const
?
This prevents me to use those properties in my own constants.dave08
11/15/2018, 5:38 PMassociateWithNotNull { }
for when the value is resolved to be null
, just like mapNotNull { }
?gabrielfv
11/29/2018, 4:30 PMIterable
class, which takes a (T) -> Boolean
predicate and returns IndexedValue<T>
?gabrielfv
11/29/2018, 4:31 PMfor (a in withIndex()) ...
rather than var i = 0; for (a in iterable) { ...; a++ }
?Mark
11/30/2018, 7:23 AMif (arg == null) null else myfun(arg)
? I can only think of arg?.let { myfun(it) } ?: null
but this seems less readable to me.spand
12/06/2018, 12:49 PMreduce
that works for empty collections by returning null
?
I can see that there are specializations of it (.minBy
, .minWith
, ..) but a general version escapes me.Dias
12/06/2018, 11:17 PMrrader
12/08/2018, 2:55 PMEither
class? https://www.scala-lang.org/api/2.9.3/scala/Either.htmlMarc Knaup
12/11/2018, 8:18 AMinline fun <R> Boolean.thenTake(action: () -> R) =
if (this) action() else null
val result = if (input) something() else null
->
val result = input.thenTake { something() }
stevecstian
12/12/2018, 9:18 AMeachCount
is not listed in https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-grouping/index.html#extension-functions now? Did I miss anything?cbruegg
12/13/2018, 7:18 PMequals
correctly, the class needs to be identical and not just be subclasses of the same type.Dias
12/17/2018, 2:44 PMShawn
12/17/2018, 2:46 PMzipWithNext
will group items together into pairs if that works for yourobin
12/18/2018, 10:19 AMSequence<T>.partition
is Pair<List<T>, List<T>>
, and not Pair<Sequence<T>, Sequence<T>>
? It would be nice to keep the lazyness even through a partitioning operation.thomasnield
12/18/2018, 9:28 PM(-4.0).pow(1.0/3.0)
, which returns NaN
due to lack of support for imaginary numbers. However, Java has Math.cbrt()
specifically for this purpose. Is this something Kotlin should explicitly support?Dias
12/19/2018, 5:00 PMString.toInt()
just an alias for parseInt()
, but String.toIntOrNull()
is custom implementation instead of trycatch implementation of parseInt()? Is it because throwing exceptions in java is heavy or something like that?rrader
12/24/2018, 1:35 PMIllegalArgumentException
with another exception? that will store property name and will be possible to get that property name and not to parse the error stringrrader
12/24/2018, 1:35 PMIllegalArgumentException
with another exception? that will store property name and will be possible to get that property name and not to parse the error stringkarelpeeters
12/24/2018, 1:39 PMrrader
12/24/2018, 1:50 PMIllegalArgumentException
karelpeeters
12/24/2018, 1:55 PMrrader
12/24/2018, 1:57 PMkarelpeeters
12/24/2018, 3:19 PMgildor
12/25/2018, 2:19 AMrrader
12/26/2018, 7:54 AMgildor
12/26/2018, 8:35 AMAnd how will be if Kotlin team will allow to disable this checksYes, you right, this check already can be disabled using compiler flag
Why not just reuse this checks?Because it not intended to be reused
And why to limit library writersI don’t see any limitation.s You already has tools to solve this problem: kotlin-reflect and kotlin-metadata
rrader
12/26/2018, 9:43 AMBecause it not intended to be reusedwhy to not make to be reused, do you know some limitations?
gildor
12/26/2018, 9:47 AMWell, as you said we also should check the compiler flagsNo! You shouldn’t if you just check it yourself
rrader
12/26/2018, 9:48 AMgildor
12/26/2018, 9:50 AMrrader
12/26/2018, 9:51 AMgildor
12/26/2018, 9:52 AMrrader
12/26/2018, 10:00 AMgildor
12/26/2018, 10:03 AMrrader
12/26/2018, 10:05 AMgildor
12/26/2018, 10:06 AMneed to create a instance of class, and need to show what field failed
rrader
12/26/2018, 10:07 AMgildor
12/26/2018, 10:07 AMrrader
12/26/2018, 10:08 AMgildor
12/26/2018, 10:08 AMrrader
12/26/2018, 10:10 AMgildor
12/26/2018, 10:10 AMrrader
12/26/2018, 10:10 AMgildor
12/26/2018, 10:11 AMI want what nullability validation to be done by other tool, not kotlin, because kotlin fail on first parahow 3rd party tool can check nullability of Kotlin types?
rrader
12/26/2018, 10:13 AM@NotNull
to that parameters, so after object creation the tool can check properties that has this annotation if they are nullgildor
12/26/2018, 10:14 AMrrader
12/26/2018, 10:14 AM@Valid
@Valid
it will validate the object before passing to methodgildor
12/26/2018, 10:15 AMrrader
12/26/2018, 10:16 AMgildor
12/26/2018, 10:16 AMrrader
12/26/2018, 10:17 AMnull
gildor
12/26/2018, 10:18 AMrrader
12/26/2018, 10:18 AMgildor
12/26/2018, 10:19 AMrrader
12/26/2018, 10:19 AMgildor
12/26/2018, 10:20 AMrrader
12/26/2018, 10:20 AMgildor
12/26/2018, 10:23 AMrrader
12/26/2018, 10:25 AMgildor
12/26/2018, 10:25 AMrrader
12/26/2018, 10:26 AMgildor
12/26/2018, 10:29 AMon can be custom, and it only works after object creation,why? Because validation checks other fields?
rrader
12/26/2018, 10:31 AMgildor
12/26/2018, 10:37 AMrrader
12/26/2018, 11:18 AMsandwwraith
12/26/2018, 2:42 PMrrader
12/26/2018, 2:45 PMsandwwraith
12/26/2018, 2:46 PMgildor
12/26/2018, 3:28 PMrrader
12/26/2018, 3:45 PMgildor
12/26/2018, 4:02 PMrrader
12/26/2018, 8:59 PMBut user will see only 1 validation errorthis is the problem, user want to see all errors at once
use default values for primitiveshm, usually you do not have default at all