Skip to main content
5 votes
2 answers
155 views

I have a generic map type where the keys have type K and the values have type V. I would like to provide a method Optional<? super V> get(K key), however it doesn't seem to work as expected. The ...
Tyilo's user avatar
  • 30.4k
3 votes
0 answers
61 views

Consider this example from book Programming in Scala, 5th Edition by Martin Odersky (Chapter 18 · Type Parameterization) Here - the following class Cat is described: abstract class Cat[-T, +U]: def ...
theutonium.18's user avatar
0 votes
1 answer
63 views

I was told that it could be possible to read a contravariance if used "Any?" as in fun processList(list: List<in Class1>) { val item: Any? = list[0] println(item) } To test ...
excitedGoose's user avatar
0 votes
1 answer
118 views

I dont know what for it is "in" TCommand keyword in that interface where TCommand is a class with a few properies needed for handler. Is it needed? What it gives in that context ? or maybe &...
Artur's user avatar
  • 139
2 votes
0 answers
104 views

As is well known, contravariance is quite rare in Rust. According to the Rust Reference on variance, only fn(T) -> () is contravariant on T. I’ve never fully understood how the following conclusion ...
phil skillwon's user avatar
1 vote
0 answers
50 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,900
1 vote
0 answers
32 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
98 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.3k
5 votes
1 answer
244 views

I have recently studied the generic concepts in Typescript. I have a problem with understanding "Why do the functions contravariance with their parameters?". I know that: Covariance is ifT ...
LeoPkm2-1's user avatar
  • 309
1 vote
4 answers
103 views

I'm writing a C# program that calculates total worth of financial assets. Each asset is represented by asset ID. There are calculator classes specialized for calculating worth of specific asset ID. ...
xa19's user avatar
  • 55
0 votes
1 answer
221 views

Is it correct, that second example in the book has direction from dynamic to object? First example has direction from string to object, I thought that second one will be from object to dynamic. To ...
Alfredo's user avatar
  • 87
1 vote
1 answer
456 views

TL;DR: Why is the Callable generic type contravariant in the arguments as stated by the PEP 483 and how is my analysis of that question (in)accurate? (Said analysis at the bottom of the post) Context:...
vmonteco's user avatar
  • 15.9k
1 vote
0 answers
54 views

I have an interface with an event with the sender as the argument. public interface IShootAttackChild { public event System.Action<IShootAttackChild> OnDestroy; /* and some functions */ }...
Szymek's user avatar
  • 21
0 votes
0 answers
29 views

I am trying to implement a dependency injection system, so that instead of instantiating all the in-depth structure of dependencies manually …: const config = new Config() const serverStarter = new ...
Parzh's user avatar
  • 10.2k
1 vote
0 answers
72 views

When I want to represent a type for *some* function, an intuitive way would be to say that it accepts an unknown argument (let's agree that all functions accept one argument): type SomeFunction = (...
Parzh's user avatar
  • 10.2k

15 30 50 per page
1
2 3 4 5
38