LeoColman
01/16/2019, 3:47 PMjw
01/16/2019, 3:48 PMLeoColman
01/16/2019, 3:48 PMLeoColman
01/16/2019, 3:49 PMisActive
inside the while
loop, and break if it's notLeoColman
01/16/2019, 3:49 PMmanueldidonna
01/16/2019, 3:51 PMisActive
as while expressionLeoColman
01/16/2019, 3:52 PMcoder82
01/16/2019, 4:30 PMDraget
05/25/2020, 8:20 PMKarlo Lozovina
05/25/2020, 9:10 PMKarlo Lozovina
05/25/2020, 9:12 PMuser
05/26/2020, 9:30 AMxii
05/26/2020, 7:18 PMKavan
05/27/2020, 7:14 AMtransfer.write_function(|new_data| {
data.extend_from_slice(new_data);
Ok(new_data.len())
})
It's really annoying to pass data by making StaticRef and get from staticCFunction and convert to kotlin type.Greg Fawson
05/27/2020, 10:02 AMAlejandro Rios
05/27/2020, 1:29 PMtodd.ginsberg
05/27/2020, 2:39 PMKarlo Lozovina
05/27/2020, 2:45 PMKarlo Lozovina
05/27/2020, 2:45 PMmyaa
05/27/2020, 5:21 PMthis
object from a delegated extension property? i'm trying to do something like this:
val Project.myProp by MyDelegate(this)
where this
should be the Project
instance that myProp
was accessed through, but i'm getting the error that 'this' is not defined in this context
if it matters, i'm trying to write an extension property for gradle
edit: sorry, i'm dumb. i forgot that delegates literally get the receiver as the first argument to getValue
. disregard this.elect
05/28/2020, 11:09 AMStefan Beyer
05/28/2020, 2:44 PM// kotlin 1.3.72
fun foo(one: Int, two: String) {
val list = listOf(one, two)
println(list)
}
I selected the listOf(one, two)
part and tried to perform the "extract function" action on it, assuming that this would result in a function like fun xxx(one: Int, two: String): List<Any> = ...
But what I actually got was an error popup saying:
Cannot extract method since following types are not denotable in the target scope:
{Comparable<{Int & String}> & java.io.Serializable}This type is kind of understandable: Int and String are both comparable to themselves and are also serializable. But I did not understand, why this would stop me from extracting a function with type
List<Any>
.
Then I tried the "Specify type explicitly" action and the type it suggested was not List<Any>
, but List<Comparable<Any>>
. With that type however, the code would not compile anymore, giving three errors:
Type mismatch. Required: Comparable<Any> Found: Int
Type mismatch. Required: List<Comparable<Any>> Found: List<{Comparable{Int & String}> & java.io.Serializable}>
Type mismatch. Required: Comparable<Any> Found: StringI am still having a hard time completely wrapping my head around variance, but I think that this is because it is
List<out T>
, but Comparable<in T>
with Int and String both having the same type as their comparable T.
Now here is my question(s):
Is this expected behavior, or should the compiler (or the Kotlin plugin?) refrain from inferring a type that has this kind of contradiction? Is this even feasible to check? I mean this only occurs because Comparable is usually used with T being the own type, like Int : Comparable<Int>
...
Edit: As a little bonus, I just saw a thing which probably really is a bug: There are 3 quickfixes for the threefold error above:
• Change type of 'list' to 'Int'
• Change type of 'list' to 'List<Any>'
• Change type of 'list' to 'String'
Yes, the second one is what is needed here, but the other ones do not make sense... Why does it suggest to make it val list: Int = listOf(one, two)
? 😅user
05/28/2020, 3:30 PMBhaskar
05/29/2020, 11:20 AMShawn Karber_
05/29/2020, 10:14 PMDerek Peirce
05/30/2020, 7:45 PMList<T>.firstHalf(): List<T>
and List<T>.secondHalf(): List<T>
extension methods that make use of subList()
, be sure to add unit tests to ensure that the middle element is included in exactly one of them.v79
05/30/2020, 7:52 PMcrummy
05/30/2020, 8:32 PMJonny
05/30/2020, 9:59 PM