Issue I have a mapper as follows protocol MapperProtocol { associatedtype T associatedtype U func map(item: T) -> U? } And I want to inject it to a class as follows protocol ParserProtocol { associatedtype T associatedtype U func parse(from:
Continue readingTag: generics
[SOLVED] Overloads vs generic arguments
Issue I have a question. In the framework, that was largely written before the generics came, you often see a function with lots of overloads to do something with different types. a) Parse(int data) Parse(long data) Parse(string data) ..etc That
Continue reading[SOLVED] Rust: return generic variable
Issue Is it possible in Rust to return generic type as collect() does?. For example: I have this function pub fn chunk<T>(&self, typ: ChunkType) -> &Option<T> { match typ { PLTE => (), GAMA => (), CHRM => (), SRGB
Continue reading[SOLVED] Call a method accepting TX as a generic type from another method with Generic Type T having List(L), with the type of (L) in C#
Issue I have a method(methodA) accepting T as a generic type and all classes (C1,C2,..) for T have a List parameter having different names and types (L). public class C1{ public List<L1> C1List{get;set;}=new List<L1>(); } public class C2{ public List<L2>
Continue reading[SOLVED] Combination of List<List<int>>
Issue I’ve a List of this type List> that contains this List<int> A = new List<int> {1, 2, 3, 4, 5}; List<int> B = new List<int> {0, 1}; List<int> C = new List<int> {6}; List<int> X = new List<int> {….,….};
Continue reading[SOLVED] TS infer parameters for each function member of an array
Issue I’m trying to create a function utility where I can pass in an array as the argument to the function, where each member is an array with the following structure: [ function, functionParams ] Basically this helper adds some
Continue reading[SOLVED] How to Create a generic method with 1 known property. Want to dynamic get the properties in different class with Generic Class property
Issue I want to practice code with DRY principle, but my method uses 2 different classes, classOneDTO and classTwoDTO.. They have different properties and I want to linked it with PRIMARYIDENTIFIER prop with both have the same.. How can I
Continue reading[SOLVED] How to search LinkedList<T> collection?
Issue I have a LinkedList<T> object where T is an arbitrary object which has a property named ID. I want search my collection using ID as search criteria. Now I know I can search it using a while loop: LinkedListNode<MyObject>
Continue reading[SOLVED] Using an Interface as a super type for Enum classes – problem with accessing Enum-specific methods
Issue I’ve been attempting to implement an interface in my enums in order to have rules for a simulation I’m making. I am trying to access enum-methods such as values() and ordinal() (on objects). However, even with upper-bounding my classes
Continue reading[SOLVED] How to pass multiple Types that implement the same interface?
Issue Firstly apologies about the not so great title, I am new to Java and wasn’t sure how to title this. I have a interface class "TestInterface": ublic interface TestInterface { String getForename(); void setForename(String forename); String getSurname(); void setSurname(String
Continue reading