Data dodania Pytanie
2018-02-13 22:02 Generics and streams: How to make this into a `StreamTuple::new` statement? »
I am working on a small library which emulates multi-value return values in Streams. For this to work well, I would like to be able to use StreamTupl...
(5) odpowiedzi
2018-02-13 14:02 Overloading, generics and type constraints : method resolution »
Consider this code snippet, featuring generics and overloaded functions : using System; namespace Test_Project { public interface Interface ...
(2) odpowiedzi
2018-02-12 15:02 C# Generic Method with Type Constraints or Base Class Parameter »
If I write a method accepting a parameter which derives from a BaseClass (or an interface), as far as I know there are two ways to achieve that: void...
(5) odpowiedzi
2018-02-09 05:02 Does List in Scala is not homogeneous collection? »
I have this following function which set the head of list with new value def setHead[A](ls: List[A], ele: A):List[A] = { ls match { case Ni...
(2) odpowiedzi
2018-02-08 08:02 Generic method not overriding similar generic method in superclass -> Which one is used? »
Given this situation: public class Animal { public <T> void genericMethod(T t){ System.out.println("Inside generic method on anim...
(2) odpowiedzi
2018-02-06 19:02 Inheriting raw types w/ conflicting generic super-interfaces »
I've come across an interesting bit of Java code that IntelliJ flags as an error, but which javac accepts as legal. Either IntelliJ is wrong, and the...
(1) odpowiedzi
2018-02-03 12:02 Catching a generic exception »
Problem I am writing a Result type in Java, and I have found a need for it to have a method that performs an operation which may fail, and then encap...
(3) odpowiedzi
2018-02-02 12:02 Generic class where type can Parse strings »
I want to create a generic class where the type of the class can Parse strings. I want to use this class for any class that has a static function Par...
(3) odpowiedzi
2018-01-29 14:01 Java: Can list hold classes implementing more interfaces »
I am writing NetworkExecutor in Java. I need my Runnable class to implement Serializable too, to be able to send it through the network. I wanted to m...
(2) odpowiedzi
2018-01-27 02:01 Generic type constraint checking »
Is it possible to write something that will fail either at compile or runtime (i.e. by any means) on invocation of just one of these methods? public ...
(2) odpowiedzi
2018-01-23 12:01 Swift: Array of equatable generic type »
I have been the last days fighting with some issues regarding generics on Swift, and I don't find a way to figure out how to achieve this: I have a ...
(1) odpowiedzi
2018-01-22 13:01 Specialize generic function requirement on protocol inheritance »
I have some protocol hierarchies on my code where I have protocols defining the objects I use and protocols defining functions to use with this object...
(1) odpowiedzi
2018-01-21 21:01 Templates(A<T>) in C# »
I want something like This: class A<T>where T: A{} A template in class extends that class too. But it has a recursive loop in A class. Any ...
(0) odpowiedzi
2018-01-20 21:01 EF Core 2.0: Determine which PropertyInfos of a generic TEntity are primary keys via reflection »
I am writing a MySQL INSERT ... ON DUPLICATE KEY UPDATE implementation via a raw SQL command in EF Core 2.0. I am very close to a working solution, bu...
(1) odpowiedzi
2018-01-20 17:01 Store Encodables in a Swift Dictionary »
I'm looking to store models objects in a Dictionary and would like to serialize the whole dictionary using JSONEncoder into data and subsequently into...
(2) odpowiedzi
2018-01-19 21:01 Ambiguous method call when overloading method with generics and lambdas »
I've noticed a weird behavior for overloading methods with generics and lambdas. This class works fine: public <T> void test(T t) { } publ...
(2) odpowiedzi
2018-01-16 14:01 How to declare generics for a method that returns a Function with generics »
I'm trying to use some kind of pattern matching in java, so i came up with this method: public Function<SimpleEntry<T, R>[], R> matchWith...
(2) odpowiedzi
2018-01-12 18:01 F# Function with variable types »
I have a question on making a function generic so that I can reuse the behavior. I have a situation where I want to perform the same set of actions wh...
(1) odpowiedzi
2018-01-12 15:01 How do I retrieve the Class for a Parameterized Class »
Consider the following code: public class Context { private final Class<?> clazz; private final String resource; private final com....
(3) odpowiedzi
2018-01-11 23:01 Kotlin Generics Error in Java »
Given the following three kotlin classes: abstract class UseCase<T> { fun execute(action: Action<T>) { } } class ConcreteUseCase...
(2) odpowiedzi
2018-01-11 21:01 Dispatch issue with generic subclass of custom table view controller »
My application has a common base class for all table controllers, and I'm experiencing a strange bug when I define a generic subclass of that table co...
(3) odpowiedzi
2018-01-11 14:01 Extension of a protocol where the associatedType is class? »
I tried something like this: protocol MyModelProtocol { var name: String { get set } } protocol MyProtocol { associatedtype Model: MyModel...
(1) odpowiedzi
2018-01-10 14:01 Scala - composing generic types »
I want to create a generic interface which hides the implementation of the hash function on the key of a product (which is used to lookup products and...
(2) odpowiedzi
2018-01-09 23:01 Covariance and Contravariance with Func in generics »
I need more information about variance in generics and delegates. The following code snippet does not compile: Error CS1961 Invalid variance: Th...
(5) odpowiedzi
2018-01-06 23:01 Python self generating variables? »
I'm writing a program which reads a big .txt file with lotto numbers. This means that there are always 7 int in one array. (6 from 49 and last one is ...
(4) odpowiedzi
2018-01-05 08:01 Why can't I use 'as' with generic type parameter that is constrained to be an interface? »
In the example below (only for demo purpose), if T is not constrained with class, then this conversion: var ret = objectA as T; ..will cause the fo...
(1) odpowiedzi
2018-01-01 00:01 Bounded variant generic becomes Any? »
I was tinkering with some generics, laziness, and implicits and hit a wall that I'm pretty sure is related only to the bounding of my generic types (b...
(2) odpowiedzi
2017-12-30 17:12 Is the invocation of a generic method allowed inside another generic method? »
I'm making a RTS game with Unity. There're many types of resources in my game, such as, tree, farm. Each resource is a GameObject and has it own main...
(2) odpowiedzi
2017-12-29 11:12 Is it possible to exclude IEnumerable and primitive types from Object parameter? »
I have this extension method: public static T Foo<T>(this Object current) where T : class, new() { ... } Is it possible to exclude primit...
(2) odpowiedzi
2017-12-29 08:12 Function with Array of Generics as Parameter in Swift »
I want to make a generic function which takes a generic array as a parameter. I have two classes Animal and Bird as well as two protocols Animals &amp...
(2) odpowiedzi
2017-12-28 18:12 Net core generic repository pattern how to inject DbContext without knowing its type at compile time? »
I'm working on a web api project decoupled and the bussiness logic its decoupled in extensions (separated projects, that gives me a lot of shared code...
(1) odpowiedzi
2017-12-24 04:12 What's with empty arrays and generics in Swift? »
Ran across an interesting bug earlier today when working with generics in Swift. I figured out a solution, but I'm wondering if anyone can answer why ...
(1) odpowiedzi
2017-12-19 15:12 In Java generic class, add extra generic constraints at constructor level? »
I have an interface called Bar and a generic class Foo parameterized on a type that is a Bar: class Foo<B extends Bar> { } My class has a gen...
(3) odpowiedzi
2017-12-18 19:12 Generic Classes With Protocols Swift »
I have a basic protocol like this: public protocol BasicSwiftClassLayout { var nibName: String { get } } and my class is this: public class Bas...
(1) odpowiedzi
2017-12-17 05:12 What does Kotlin's type reification make possible that is not possible in Java or Scala? »
I am most familiar with Java type erasure (with all its issues and benefits). I have some limited exposure to the expanded possibilities with Kotlin's...
(2) odpowiedzi