Generic return type upper bound

My question is an extension of this post. My question is relative to returning a generic List: the type of the returned list in the provided example works but why ? If I have a method like this: public static <E extends CharSequence, T extends ...
more »

2017-06-21 22:06 (0) Answers

How to create a nested List of derived classes

I'm writing an application to deal with WMI objects. I have a Computer class with a List<Component> property, being Component an abtract base class from which come all the derived classes such as Monitor, ComputerUnit, Printer and so on. Cons...
more »

2017-06-21 13:06 (3) Answers

Create Generic Component With T in Constructor

I'm trying to make a generic component to display list resources. I'm running into issue instantiating the component in HTML. I was using this answer to attempt to fix the problem but I feel it will not work. I have this Component <ion-list>...
more »

2017-06-21 04:06 (1) Answers

Swift use value as generic

I could not find a way to use a value in a generic class definition instead of a class or protocol. For instance we often find a number of matrix classes like SCNMatrix3, SCNMatrix4 while it'd be nicer to be able to define a more generic Matrix<a,...
more »

2017-06-20 23:06 (1) Answers

Generic pattern matching and type erasure

The goal is to write creator function, define what kind of message actor can receive, and match this kind of message inside actor. So i want to specify that my expected message is of type X (i know this type only when i call create function) I have ...
more »

2017-06-20 23:06 (1) Answers

Protocol Extension of Constrained Dictionary

I'm trying to get a specific Dictionary type to conform to a protocol. typealias FirebaseDictionary = Dictionary<String, FirebaseValue> I would like to have the conform to a FirebaseValue protocol protocol FirebaseValue { // stuff here ...
more »

2017-06-20 23:06 (0) Answers

Nested generics in a swift function

Assume I have this bit of code: protocol MyProtocol { } struct MyStruct: MyProtocol { } class MyClass<P: MyProtocol> { // Required for compiling required init() { } } class MySpecialClass: MyClass<MyStruct> { } func foo&l...
more »

2017-06-20 22:06 (2) Answers

return Class object based on condition in c#

How to Return a class object on different condition. Suppose if my result is success return Authentication, else return Class Error. Here is my code Public Class Example { Public Authentication GetDetails(int id) { Authentication o...
more »

2017-06-20 21:06 (1) Answers

Generic conversion to Numeric

I would like to write a generic conversion function converting a sequence of Doubles into any Numeric class, something along the lines of: def construct[T : Numeric](a: Seq[Double]): Seq[T] = { val n = implicitly[Numeric[T]] { value ...
more »

2017-06-20 10:06 (1) Answers

WinForms Custom Controls and Generics

I have a subclassed DataGridView with a DataSource of SortableBindingList<T>. I use this thing everywhere, with the same underlying configuration. The current subclassed version mostly changes the designer defaults for properties, so they d...
more »

2017-06-20 07:06 (1) Answers

Modeling an interface with a generic array

I would like to model an interface that has array that accepts objects as long as they extend a particular interface. I'm still learning Generics, so please bear with me. Here's my "base" interface: export interface IEntry { sys: { contentTyp...
more »

2017-06-20 05:06 (1) Answers

Using the JGraphT library's EdgeProvider class

I've looked all 'round for a solution, but due to my not having much experience with Java's generic programming style, I'm a bit stumped on what words to even use to search this. I am trying to use the DOTImporter (
more »

2017-06-20 01:06 (0) Answers

Confused about bound parameters (Java Generics)

I am going through the Java Generics tutorial, and I am a bit confused. It is the error message in this example that confuses me, I am not sure where inspect(10) comes from? Box.j...
more »

2017-06-19 18:06 (1) Answers

Java convention for unknown return type method

I'm working on a workflow engine that will help customers to define their workflow on our product. In this workflow engine, i made a system of condition to go or not to the next step, but these conditions can be everything. Like comparing execution ...
more »

2017-06-19 15:06 (1) Answers

c# How To Use .Contains on Generic IEnumerable<T>

I'm trying to create a generic method that I want to use for mixing a list of objects based off a property. Optionally, you can supply a list of list objects to merge some groups together. This works fine as a non-generic method and when I code the p...
more »

2017-06-19 12:06 (3) Answers