Skip to main content
3 votes
1 answer
60 views

In Kotlin, the removeAll extension function on MutableCollection with Iterable argument is defined as (see reference here): @IgnorableReturnValue fun <T> MutableCollection<in T>.removeAll( ...
John's user avatar
  • 125
3 votes
1 answer
69 views

In Kotlin, the plusAssign (+=) operator function on MutableCollection with Array argument is defined as (see reference here): inline operator fun <T> MutableCollection<in T>.plusAssign( ...
John's user avatar
  • 125
-2 votes
1 answer
71 views

I want to keep some graph traversal algorithms as generic as possible and define a protocol for this purpose: protocol Path { var distance : Int { get} var end : Node { get } init (start:...
Christophe's user avatar
  • 75.2k
4 votes
1 answer
108 views

I have a simple question about covariance/contravariance here. Below, I have a Func<T1, T2> that I need to be casted to Func<T1, object>. In theory, this should be possible, but in ...
Daniel Möller's user avatar
0 votes
0 answers
31 views

I have relational data, i.e. observations for pairs of objects. More specifically these are migration rates between plant populations, which I would like to explain by a predictor. The migration rates ...
Tobias Naaf's user avatar
Advice
0 votes
8 replies
115 views

The problem I am trying to solve is representing a partially loaded tree of objects using C# generics. For example, suppose we have the following classes: public class Address { public string ...
Jeremy Salwen's user avatar
4 votes
1 answer
190 views

From the official docs: The introduction of explicit syntax for generic classes in Python 3.12 eliminates the need for variance to be specified for type parameters. Instead, type checkers will infer ...
Leonardus Chen's user avatar
2 votes
1 answer
73 views

Method parameters should be contravariant, hence defining a covariant generic should raise a type error. However when using a covariant generic in a union pyright, mypy and pyre-check all do not ...
Daraan's user avatar
  • 5,300
2 votes
1 answer
93 views

I have the following code. The compiler complains about the last line. I am wondering why. The WrappedFunction case class takes a function object with trait arguments. When I try to construct a ...
user3068137's user avatar
1 vote
0 answers
43 views

Probably there is a duplicate question somewhere but I'm not sure what the correct search terms are. Since a snippet says more than a thousand words: why is this not valid C#? class A<T> { } ...
CompuChip's user avatar
  • 9,252
1 vote
0 answers
57 views

Can any body help me in succesfully typecasting the derived class object which in real application created from Dependency Injection and retrieved from builder.Services. I am typecasting it to base ...
Usman's user avatar
  • 2,920
0 votes
1 answer
70 views

I have tried a number linear regressions, and though the standard ones are all good (e.g., lm.fit is really nicely fast), the fastLM in https://www.rdocumentation.org/packages/RcppEigen/versions/0.3....
ivo Welch's user avatar
  • 3,098
2 votes
2 answers
105 views

I'm working with a union type of two instances of a generic class. These instances have different property shapes, but they also share common properties. I'm encountering an issue when trying to ...
stambolievv's user avatar
1 vote
0 answers
34 views

I think TS fails to warn against an invalid method override. In the following code, Dog extends Animal. But Dog is a consumer of DogFood, a subclass of Food, and Animal is a consumer of Food. So the ...
Tilt's user avatar
  • 41
5 votes
0 answers
99 views

If you have something like this, struct Foo { }; constexpr auto pred = [](){ return Foo{}; }; calling std::not_fn(pred) will fail to compile, expectedly. However, adding an explicit conversion ...
Enlico's user avatar
  • 30.5k

15 30 50 per page
1
2 3 4 5
130