Category "generics"

How to add an entry with an Integer value into Map<String, ?>

I have to place an integer value into the map below. Map<String,?> map map.put("key",2000); When I run the above code I'm getting the following error: in

Dart Generics - type is not a subtype

I'm getting a runtime error from a Dart generic function: Widget card = widget.cardBuilder(item); Which generates: type '(Contact) => Widget' is not a

Jackson deserializer for generic type

I need to write a custom deserializer for a class with generics. I couldn't find a way to do this, however I cannot imagine I'm the only one with this problem.

C# check object type against multiple types

IS there a way to pass an array of types to the "is" operator? I am trying to simplify the syntax of checking an object against multiple types. Something like

Does Java have a similar post method diamond operator that C# has?

The Unity project makes frequent use of C# functions that supply a type in a diamond operator after the method name. In the Unity source code it's defined like

MapStruct - Map Generic List to Non-Generic List containing different types

I am attempting to use MapStruct to convert between 2 internal models. These models are generated from the same specification and represent a large tree-like st

Is it possible to inherit from class with Generic in Python?

Since Python 3.5 you can use Generics and other interesting stuff described in PEP-0484. I tried that and here's a code I have: from typing import TypeVar, Ge

Use generic in type alias

My type annotations I currently have look similar to the following, and I want to use an typing alias to not repeat myself so much: A class has class variables,

incompatible types: Myclass cannot be converted to CAP#1 where CAP#1 is a fresh type-variable:CAP#1 extends Myclass from capture of ? extends Myclass

In code I created user defined class Myclass and Myclass2 which extends Myclass and then used in ArrayList<? extends Myclass> as a arguments that means no

Generic function that returns different types based on the value of an argument

I have a struct which holds registers. I want my read_register function to return a u8 for Register::V0 and Register::V1 but a u16 for Register::V2 and Register

.Error CS1061 'Task<IEnumerable>' does not contain a definition for 'Where' and no accessible extension method 'Where'

My generic repository is as follows ( I have similar in synchronious and it works) public virtual async Task<IEnumerable<TEntity>> GetAsyn( Expr

How to write a method that takes in a List of Integer, Float, Double and calculate the average?

I am trying to write a method that takes in a list of numeric values - eg List<Integer>, List<Float>, List<Double> etc - and give me the avera

How to write a method that takes in a List of Integer, Float, Double and calculate the average?

I am trying to write a method that takes in a list of numeric values - eg List<Integer>, List<Float>, List<Double> etc - and give me the avera

Unity: Generic Method to get or add a component

Every time I make a new Script in Unity, I always end up doing a bunch of checks for any components my script depends on, like: SpriteRenderer sr = gameObject.

TypeScript Generics column.id should be within row[key]

I'm writing a TypeScript Interface for Tables: interface Column { id: string; label: string; } interface Data { [key: string]: string; } interfac

What is the "any" type in Go 1.18?

In Visual Studio Code, the auto-complete tool (which I presume is gopls?) gives the following template: m.Range(func(key, value any) bool { }) where m is

A Swift protocol requirement that can only be satisfied by using a final class

I'm modeling a owner/ownee scheme on Swift: class Owner<T: Ownee> { // ... } protocol Ownee { var owner: Owner<Self> { get } } Then I h

Issue with Unmarshalling GRPC Response To Generic Type

I am trying to use generics to convert a JSON object into a GRPC response that has an enum, i.e.: type GRPCResponse { str string enu EnumType } type En

Convert func(T) to func(any) [duplicate]

I want to be able to enforce similarity between two fields of a struct but also have several of these structs in a map or slice. Here's a simp

Check if Object is Dictionary or List

Working with .NET 2 in mono, I'm using a basic JSON library that returns nested string, object Dictionary and lists. I'm writing a mapper to map this to a json