Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
32 views

Typescript Generic and Non-Generic Version of Type 2 -Define VOID property?

To build off of the question found here: Typescript Generic and Non-Generic Version of Type The question asks: "how to have a generic and non-generic version of a typescript type" like ...
emery.noel's user avatar
  • 1,193
0 votes
0 answers
49 views

C# - Can the JIT optimize generic type checking? [closed]

I am attempting to make a parse function to parse common types from a string such that; public static T FromSpan<T>(string Value) { if (typeof(T) == typeof(string)) { return (T)(...
Second Dimsey's user avatar
0 votes
1 answer
45 views

Swift generic specialized type prevents protocol conformance

In swift, given the following protocols protocol Mark {} protocol Detector { associatedType ViewType: View func check(mark: some Mark) -> ViewType } Non-specialized ContentView compiles ...
Geob's user avatar
  • 614
2 votes
1 answer
54 views

How to document what the generic type parameters of a Func are? [closed]

Suppose you have a property which is a Func<T1, T2, TResult>. How do you provide inline documentation for what T1 and T2 are? Example: public class MyClass { /// <summary>Checks ...
Rush Frisby's user avatar
  • 11.5k
1 vote
1 answer
51 views

Swift protocol function requirement with both generic function arguement and generic return type

For a protocol protocol Mark {} Why would this compile 👉 generic argument only protocol Detector { func check(mark: some Mark) } class Vision: Detector { // conforms func check(mark: some ...
Geob's user avatar
  • 614
-1 votes
1 answer
88 views

Go argument concrete type checking [duplicate]

Given the following example package main type I interface { Do() } type S struct {} func (s *S) Do() {} func Handler(h func (i I) error) { // ... } func Wrapper(i I) func (i I) error { ...
lccmrx's user avatar
  • 135
0 votes
2 answers
118 views

How to make a Java static function, which returns an instance of its parent class, generic?

I have some code that I'd like to make more generic - at the moment it uses one enum (which I've loaded up with various other fields and static objects) and I'd like to be able to extend it to use ...
afarrell's user avatar
0 votes
3 answers
71 views

How to take a list of parent class objects and create a list of child class objects that the original list was created with? [closed]

I am not very proficient in Java. I am using java 1.8. I have the following class structure. class Parent { } class Child1 extends Parent { } class Child2 extends Parent { } . . . class Childn ...
user2125853's user avatar
  • 1,343
-1 votes
0 answers
67 views

Nullable out parameter in generic method can't be null

I am struggling a bit to write a C# method that will return null instead of default in certain situations but it seems tricky given that the types are generic and that the constraints (when applied to ...
jonseesharp's user avatar
7 votes
1 answer
190 views

Why is the Unit type treated in a special way in Kotlin?

Please explain this behavior in Kotlin: data class A<T>(val p: T) class B fun f1(): A<Number> = A(B()) as A<Number> fun f2(): A<Unit> = A(B()) as A<Unit> fun main() { ...
user30224617's user avatar
0 votes
0 answers
71 views

Is it possible to get rid of redundant generic parameters [duplicate]

I tried to look around first, and I suppose this question is similar, but the Jon Skeet's answer, though accepted, is a bit too laconic for me. Besides, my situation is a bit different. First, the ...
Roger Wolf's user avatar
  • 7,732
1 vote
0 answers
48 views

Why does the compiler fail to find the correct function? [duplicate]

I have this generic function: pub fn bounding_circle<V>( points: &dyn Fn(usize) -> V, point_count: usize, ) where V: InnerSpace<f32> + Debug + Copy, for<'x> &...
Makogan's user avatar
  • 9,708
-1 votes
1 answer
93 views

Why does Go not support generics in struct fields? [closed]

I have SpendingCreateEvent SpendingDeleteEvent SpendingUpdateEvent These are events that have similar fields. All of the events (SpendingCreateEvent, SpendingDeleteEvent, SpendingUpdateEvent) have ...
ilya_dt's user avatar
  • 53
1 vote
2 answers
114 views

Can't convert Supplier<S> into Supplier<?>

I have a very simple Java class that looks like this public class StatementRegister { public static final Map<String, Supplier<Statement<?>>> registry = new HashMap<>(); ...
slit bodmod's user avatar
1 vote
3 answers
45 views

Instance of abstract class with generic type coming out as never when it's narrowed

I was in need of a way to change the parameters and return type of a class function if a field from this class is true, taking into account that i have an abstract class and a bunch (more than 6) of ...
Silver Stitch's user avatar

15 30 50 per page
1
2 3 4 5
3354