karelpeeters
01/10/2019, 7:08 PMMap<Any, V>
karelpeeters
01/10/2019, 7:09 PMAndrew Gazelka
01/10/2019, 7:09 PMAndrew Gazelka
01/10/2019, 7:09 PMNir
12/17/2020, 10:26 PMNir
12/17/2020, 10:27 PM123
12/18/2020, 4:41 AMCannot resolve plugin org.jetbrains.kotlinkotlin maven plugin1.4.21Had anybody encountered same?
user
12/18/2020, 11:34 AMLeoColman
12/18/2020, 1:44 PMfun main() {
val response = foo<String>(Bar().boot())
}
fun <T> foo(x: Bar<T>) = listOf(x)
class Bar <U> {
fun boot() = this
}
It seems to me that the compiler should have enough information to infer U
, as it must be T
100% of the timesuser
12/18/2020, 3:25 PMMarcus James Bowden
12/18/2020, 4:48 PMuser
12/18/2020, 5:11 PMNir
12/18/2020, 7:28 PMinterface Dimension {
val dimension: Int
}
object DimThree : Dimension {
override val dimension = 3
}
etc
Now suppose I have these users of said interface
data class Point<D : Dimension> private constructor(val data: List<Int>) {
constructor(d: D, init: (Int) -> Int) : this(List(d.dimension, init))
}
operator fun <D : Dimension> Point<D>.plus(p: Point<D>) = Point(<need an instance of D>) { this.data[it] + p.data[it] }
As we can see, I need an instance of D there, which should be trivial since D is monostate in practice. The question is, is there any way to define my interface Dimension, so that if I have a D: Dimension
, I can obtain an instance of D
?
The only solution I have found here so far, not very nice is to have each Point store a D; this is a waste of space since a Point<D> already knows this informationNir
12/18/2020, 7:29 PMAnimesh Sahu
12/19/2020, 9:57 AMuser
12/21/2020, 6:00 PMuser
12/22/2020, 9:42 AMuser
12/22/2020, 4:33 PMuser
12/22/2020, 4:57 PMNir
12/22/2020, 10:17 PMNir
12/22/2020, 10:21 PMuser
12/23/2020, 7:57 AMuser
12/23/2020, 2:17 PMuser
12/23/2020, 4:04 PMIfvwm
12/24/2020, 10:06 AMCircuitRCAY
12/25/2020, 1:39 AMfun overload(message: String)
fun overload(message: ByteArray)
CircuitRCAY
12/25/2020, 1:40 AMEsa
12/25/2020, 9:07 PMEsa
12/25/2020, 9:09 PM