Category "generics"

swift generics: append not found for array

My first attempt to use swift generics: extension RealmSwift.List where Element == Object { // @deprecated use RealmSwift.List<> func arrayo<T:

Return type of generic function

I'm trying to make getResults function return the proper type, but currently stuck with this: interface IResponse<T> { result: T; } type FnType<P,

typescript infer object value from key

I have a map of components like this: import { Select, Input, DatePicker } from 'antd'; const MyComponentMap = { Select, Input, DatePicker } I'm try

In Go generics, how to use a common method for types in a union constraint?

I'm trying to understand the usage of the type union constraint in Go generics (v1.18). Here is the code I tried: type A struct { } type B struct { } type AB

Iterate over the fields of an object

I have a singleton objet with 100 different case classes. For example: object Foo { case class Bar1 { ... } ... case class Bar100 { ... } } I would like to

`#[derive(Clone)]` seems to wrongfully enforce generic to be `clone`

It seems that when deriving Clone, Rust forwards the Clone trait requirement to Generics that do not require the trait, like if they are wrapped inside an Arc.

Blazor Generic SelectList not showing checked items on load

I am using a generic SelectList to render a list of checkboxes. I can check items and save them to the users record without problems. But on retrieving the user

Custom utility types (generic types) for classes `IsClass` of TypeScript

I am trying to create a generic type to make sure the first parameter to be a class. However, the factory function parameter cannot be replaced by a generic typ

Differentiating custom Typescript Interfaces that have the same fields

I have a custom interface like this: interface Pointer<T> { id: string } id is a pointer to other data structures, but the id field doesn't contain inf

How to get generic types of subclass in Python

I have a generic parent class and a child class that implements the parent with a specific type: T = TypeVar("T") class Parent(ABC, Generic[T]): def get_im

How to use Kotlin generics to access same fields in sibling classes

data class Type1(val str: String) data class Type2(val str: String) interface Person data class Child1(val name: Type1) : Person data class Child2(val name: T

Preserve Type Restriction between Generic Variables

Assume that we have some class that has an important generic variable T and another class we have two fields, one wrapped, and one not: class Wrapper<V> {

Indexing object with a generic key

First time I've run into this issue so apologies if the title doesn't make sense, couldn't figure out a good way to word it. I'm working with an API that return

How can I make a typescript generic less specific?

When typescript captures generics it captures them very specifically which can lead to complications. How can I make this "LessSpecific" type dynamically return

Typescript, merge object types?

Is it possible to merge the props of two generic object types? I have a function similar to this: function foo<A extends object, B extends object>(a: A,

How to create a generic buffer in TypeScript?

I have the following class: export class BufferData { arr: Float32Array; index: number; constructor() { this.arr = new Float32Array(8); this.inde

Java initialize array with mutiple type parameters error java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to

public class ArrayPQK<P extends Comparable<P>, T> implements PQK<P, T> { int maxsize; int size; int head,tail; Pair<P, T>[] nodes; publi

How to check if the value of a generic type is the zero value?

The generics proposal has a section on how to return the zero value of a type parameter, but it does not mention how to check if a value of a parametrized type

How to solve "interface method must have no type parameters"?

I'm trying out go generics in 1.18beta2 and I'm trying to write an abstraction layer for key/value store, boltdb. This is what I'm trying to achieve with it. ty

Go generics: invalid composite literal type T

package main import ( "google.golang.org/protobuf/proto" ) type NetMessage struct { Data []byte } type Route struct { } type AbstractParse interface