Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
21 views

Rust generic lifetime elision issue

I am trying to a implement generic observable collections for use with a UI framework I'm writing. I'm currently having an issue with lifetimes not being elidable in generics. For brevity the ...
Jacob Green's user avatar
0 votes
0 answers
22 views

check if given object implements certain generic interface; type argument(s) NOT known [duplicate]

I have some object. I want to check at runtime if it is an IReadOnlyCollection<T> of any T, i.e. I cannot specify that T in my check. So it should return true for e.g. IReadOnlyCollection<...
Kjara's user avatar
  • 2,794
-2 votes
0 answers
38 views

Returning an array of raw type but instead of an array of parameterized type specified at the header

protected Collection<Node> createBucket() { return new LinkedList<>(); } /** * Returns a table to back our hash table. As per the comment * above, this table can be an array of ...
Pius's user avatar
  • 1
1 vote
2 answers
73 views

Can't understand the reason for this Typescript generic issue

I am learning TS and have the following code: function getOrDefault<T = string>(value: T, defaultValue: T, car: T): T { return value || defaultValue; } const strValue = getOrDefault("...
j obe's user avatar
  • 1,969
0 votes
2 answers
33 views

Generic types dependencies between function arguments

I'm trying to use binding for a game engine. And I want to add a little typing /** Engine external functions */ export type Message<TBody> = { } // This function returns same unique object for ...
Onni's user avatar
  • 11
0 votes
1 answer
86 views

Should I prefer `dynamic` or `Object?` for generics in Dart?

I've been trying to understand how I should enforce the strict-raw-types rule from Dart, and make sure my code adheres strictly to the type system. I understand the difference between dynamic and ...
Luan Nico's user avatar
  • 5,652
3 votes
1 answer
126 views

What is the difference between the types Null and Null & T where T <: AnyRef?

Look at the following method def toOption[T <: AnyRef](value: T | Null): Option[T] = value match { case null => None case content: T => Some(content) } If you ...
Readren's user avatar
  • 1,216
0 votes
0 answers
61 views

How to specialize the return type of a method in Kotlin

I want to implement a specific persistence in Kotlin, where I need to wrap the object to be persisted; yet, I still want to access some part of the persisted (generic) object in a type-safe way. How ...
Ulrich Schuster's user avatar
0 votes
1 answer
39 views

Subclassing a generic Kotlin class with type constraint

I'm running into problems combining subclassing polymorphism and generics (ad-hoc polymorphism) in Kotlin. Here are my type definitions: interface State interface StatefulContainer<out S : State&...
Ulrich Schuster's user avatar
0 votes
1 answer
51 views

Scala type mismatch error involving generics and refined types

The following is a simplified version of a type-mismatch error I'm trying to solve: trait Foo[A] { type B val b: B } trait Bar[T, R[_]] { val r: R[T] } object TypeMismatch extends App { def ...
lewistg's user avatar
  • 338
1 vote
1 answer
33 views

Use TS Generics for a object using another object key and value type

I'm having some trouble using Generics in typescript. I want to create an object based on another object type using Generics. My starting point was this doc from TS This is what I have come up so far: ...
Artur Moreira's user avatar
1 vote
0 answers
20 views

Conditional types incorrectly infer union types [duplicate]

I am trying to write a function that conditionally infers the type of a generic input parameter that is a union. When I make the input type conditional, it throws an error showing that it infers the ...
David Y. Stephenson's user avatar
0 votes
2 answers
39 views

C# Generic Method passed as argument, Argument type 'bool' is not assignable to parameter type 'System.Func<bool>'

I am attempting to create a generic array iterator which goes iterates through a multidimensional array assigning each element with the result of a function. When trying the following code I get the ...
Max Heinze's user avatar
1 vote
1 answer
78 views

How do I get a type safe function return value in this case?

In the below code example I would like my IDE to accept mySap.rootValues[0].test2 and mySap.rootValues[1].test4 as valid. Right now, it doesn't, because rootValues[0] and rootValues[1] are of type ...
msbb's user avatar
  • 53
0 votes
0 answers
23 views

Bound and Unbound types in C# [duplicate]

Bound and Unbound types in C# The term unbound type refers to a non-generic type or an unbound generic type. The term bound type refers to a non-generic type or a constructed type. What does an ...
Logeshkumar S.'s user avatar

15 30 50 per page
1
2 3 4 5
127