Why does Java complain about use of generics in map but not list?

I need to generically process a map containing a list, but can’t get by the compiler warning. It doesn’t make sense why I can generically process the list, but not the map. From the below code, why does the compiler allow the ‘processList’ method call, but not the call to ‘processMap’? It doesn’t seem to… Read More Why does Java complain about use of generics in map but not list?

How can I move a generic TS argument definition without getting the "Property doesn't exist on type 'unknown'" error?

I’m confused as to why the definitions of doSomething1() and doSomething2() are not treated equally? class Example< TypeA = void, TypeB = void, ArgsType = { valueA?:TypeA, valueB?:TypeB } > { valueA?:TypeA; valueB?:TypeB; constructor( valueA:TypeA, valueB:TypeB ) { this.valueA = valueA; this.valueB = valueB; } doSomething1( args: { valueA?:TypeA, valueB?:TypeB } ) { // this… Read More How can I move a generic TS argument definition without getting the "Property doesn't exist on type 'unknown'" error?

Method to return a generic type when passing in a generic delegate

I want to: return a generic type, can be for example ICollection OR string, needs to be flexible. this will be returned by the restapi client that consumes the api.(different endpoints have different return types) pass in some kind of delegate containing the method to be called from the actual rest client. rest client is… Read More Method to return a generic type when passing in a generic delegate

Can I mix inferred and exlicit generic type parameters in Kotlin?

Assum I have this extension function: inline fun <reified R> Any.getPrivateProperty(variableName: String): R { … } I can quite conveniently call this with something like s.getPrivateProperty<Int>("height"), an expression that is of type Int. Now I wanted to make sure the function is only defined on non-optional types. I used the definitely-not-nullable notation: inline fun <T:… Read More Can I mix inferred and exlicit generic type parameters in Kotlin?

How to convert known type to pointer to type parameter in a switch?

I’m trying to write a function which converts a byte array of JSON string to another in accordance with the type parameter of the return value as the following rule: map[string]interface{}: convert to map[string]interface{} []byte: no conversion, return as is struct: convert to the struc My code is as follow: func GetJsonData[T any](jsonByteArray []byte) (result… Read More How to convert known type to pointer to type parameter in a switch?