Category "generics"

In AnyLogic, how can I use the findFirst function but for three different agent populations / data types?

Question: Is there a way to write one function that would account for the different data types? Would generics work and if so how do you do that in AnyLogic? Ba

BubbleDown function(min heap) not working

I have generated a minheap to this file but I think something I have missed but I can't identify what are the things I have missed. I have missed something on

What is the best way to work with classes that subclass from Generic types?

Assume we are given a generic class definition such as: from dataclasses import dataclass from typing import TypeVar, Generic, List T1 = TypeVar('T1') T2 = Ty

Is there a way in Golang Generics to create something like "extends" in Typescript?

I am trying to create a function using Go Generics that accepts any structs that meet minimum struct criteria. Something like <T extends {name: string, age:

Generic delegate response handlers

I've got a class currently something like this class Client { var responseOneDelegate: ResponseOneDelegate? var responseTwoDelegate: ResponseTwoDelegat

Generic Structs with Go

What is the equivalent of this C# code in Go, how can I build it class ModelX<T> { public T Data { get; set; } } ModelX<int>

Why does Go not allow assigning one generic to another?

Following code throws a compilation error cannot use ExampleProps (variable of type Props[Example]) as Props[Generic] value in return statement // Abstract ty

Kotlin Mockito Generics

Suppose my class is: open class TestThis{ @Autowired private var myService : MyService? = null fun doMyFunction(){ val result = myService.d

Why am I getting TypeError at runtime with my generic StatefulWidget class?

I have a generic StatefulWidget class that has a Function callback. When I try to invoke that callback, I get a runtime TypeError: ══╡ EXCEPT

<E> and <Object> differences and usage

Can someone explain me what are the differences by using E or Object for example in a class for Lists, and their singular usage and definition. I have to use th

TypeScript function that works on all numerical array types

I am trying to write a function that works on all of the JavaScript array types, e.g. on number[], Float32Array etc. It should return the same type that it gets

Type erasure Generics

An error occurs at new T[5] during compile-time saying => error: generic array creation and according to my understanding, the array is created during compil

The type 'T' must be a reference type in order to use it as parameter 'T' in the generic type or method 'TableClient.QueryAsync<T> [duplicate]

I'm using 12.0.0-beta.6 of the Azure.Data.Tables nuget package. When I try to invoke TableClient.GetQueryAsync it gives me the error: "The typ

Android generic Gson.fromJson() conversion with coroutine and flow

I am making generic classes for hitting otp api.anybody can use otp section just have to pass request ,Response class and url and all will be done by this otp s

How do you implement a trait for T where T: Foo OR Bar

In rust, you can automatically implement a trait for any type that implements some other combination of traits. Ie: impl<T: Foo + Bar> SomeTrait for T {

What is struct Cleaner <T*> mean?

What is struct Cleaner <T*> mean? Is it specific the second Cleaner can only accept the type of pointer? what is the terminology of this usage in C++? te

How to create generic method in Go? (method must have no type parameters)

Golang 1.18beta supports generic, I want to add an extension method on a generic slice. e.g. a map function is defined as this: func Map[E, V any](slice *[]E, i

In a Java interface, is there a way to return an enum nested in a generic type?

I'm looking for a way to return an Enum type nested in a Generic class. Here's what I mean: public interface MapperClass<E, D> { D entityToDto(E enti

typescript generics class, method parameter and method return type

I have this function function getCollection<T>(collectionType: T): Collection<T> { return new Collection<T>() } and in Collection class I h

Function type cannot have type parameters

I am trying to write a sample program to try and implementing the a data structure using go generic proposed in go2. As part of this I want to define a iterator