Category "generics"

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

What is the "proper" way to cast Hibernate Query.list() to List<Type>?

I'm a newbie with Hibernate, and I'm writing a simple method to return a list of objects matching a specific filter. List<Foo> seemed a natural return typ

Difference between any/interface{} as constraint vs. type of argument?

As generics have been released in Go 1.18 pretty recently, I've started learning them. I generally get the concept, because I have some Java experience from the

How jasmine spyOn a generic method

I try to make a spy on a generic method in typescript, but cannot get Jasmine to recognise it. I have code http: HttpClient <- Not proper code, just showin

Nim - How to access mytype of a field that has the type Option[mytype] at compile time?

Heyho, While coding my way through some generics I stumbled upon an issue with one of my generic functions. I have 2 types such as this import std/options impor

How to pass one SwiftUI View as a variable to another View struct

I'm implementing a very custom NavigationLink called MenuItem and would like to reuse it across the project. It's a struct that conforms to View and implements

Generic callback with generic class as parameter in Dart

I wrote a custom switch class in Flutter to implement generic parameters, I used the flutter_switch package. When I toggle the switch I faced the following erro