generics Questions
2
This is a follow up to this question, Restricted access for allocated arrays belonging to separate object, after discovering that returning by value across compilation units doesn't help to hint th...
Fauch asked 21/10 at 18:23
2
Solved
Feature for deserializing Generic Classes was introduced to freeze a few months back.
I am trying to follow the documentation, but I am facing a compile time error:
The argument type 'NameOfClass F...
Obsequies asked 30/9, 2022 at 6:56
3
Solved
I have a Collection, I'm trying to use the Distinct method to remove duplicates.
public static Collection<MediaInfo> imagePlaylist
imagePlaylist = imagePlaylist.Distinct(new API.MediaInfoCo...
Gwen asked 30/12, 2011 at 5:15
3
Solved
I've searched and have found answers that make sense when you have access to change an existing interface definition. In my case, I do not have that ability. I'm trying to create a new object with ...
Victorie asked 7/10 at 19:38
4
Solved
Imagine I have the following struct:
type MyGeneric[T string | int] struct {
}
I want to check whether the generic used to instantiate that struct was a string or a int when creating a new MyGener...
Leukoderma asked 27/9, 2022 at 8:45
0
I can't figure out why I need a 'static bound in one case (bar) and not the other (baz):
fn f<T>(_input: T) -> bool {
false
}
fn bar<T>() -> Box<dyn Fn(T) -> bool + 'stati...
6
I am very new to TypeScript. My TypeScript version is 3.7.5.
IMHO, it should be very easy, but I don't know why it does not work.
function add<T> (a:T, b:T):T {
return a + b ;
}
console.log...
Septarium asked 18/1, 2020 at 17:11
3
Solved
It's incredibly impossible to find things for FreePascal because all searches end up at some sort of Delphi related site.
Is there a built-in Dictionary object?
This page references "TDictionary...
Pteridophyte asked 2/4, 2013 at 21:45
5
I know that in Java generics when using a type parameter with multiple bounds,the compiler erases the type information to "the leftmost bound" (i.e. the first class/enum or interface that's on the ...
Garold asked 26/12, 2015 at 11:56
3
Solved
I want to write my enum with custom attributes, for example:
public enum SomeEnum: long
{
[SomeAttribute<MyClass1>]
Sms = 1,
[SomeAttribute<MyClass2>]
Email = 2
}
but attributes ...
Plebeian asked 23/10, 2014 at 5:9
1
a variable annotated with Type[C] may accept values that are classes themselves
How do you do this with TypeVarTuples (PEP 646)
from typing import TypeVar, TypeVarTuple
T = TypeVar("T")
...
Groundsill asked 1/5, 2023 at 23:55
3
Solved
Crashes in Firebase Crashlytics appear with a note how to fix a problem:
Fatal Exception: java.lang.IllegalStateException: TypeToken must be created with a type argument: new TypeToken<...>()...
Boiardo asked 11/5, 2023 at 7:7
3
Solved
I'm running PHPStan on a Symfony project where I have the following relation in a Doctrine entity:
/**
* @ORM\OneToMany(targetEntity="App\Entity\Course\Slide", mappedBy="chapter", cascade={"persi...
Ermine asked 24/4, 2020 at 22:15
2
My type annotations I currently have look similar to the following, and I want to use an typing alias to not repeat myself so much:
A class has class variables, which can be either:
some specified...
Discriminate asked 26/5, 2019 at 21:14
4
I want to implement a function that loops over the properties of an object and applies updates to another object of the same type.
interface Car {
tires: number;
name: string;
}
function updateC...
Buxtehude asked 25/8, 2020 at 9:42
4
Solved
I have this class structure (simplified):
public class InducingMedium
{
public required string File { get; set; }
}
public class InducingVideo : InducingMedium {}
public class InducingAudio : Ind...
7
Solved
Assume you have a Python class that inherits from Generic[T]. Is there any way to get a hold of the actual type passed in from within the class/instance?
For example,
from typing import TypeVar, Ty...
Necropsy asked 29/8, 2019 at 8:32
4
Solved
Does C# offer some nice method to cast a single entity of type T to IEnumerable<T>?
The only way I can think of is something like:
T entity = new T();
IEnumerable<T> = new List { enti...
Uis asked 10/2, 2011 at 16:51
2
Solved
I have a JSON string and I created a function which parses this JSON as an object using Scala case class. I wrote the below code to parse it in a generic way. However, It gave me an error:
def get...
4
Solved
In C# 8 with nullable enabled, is there a way to identify a nullable reference type for generic type?
For nullable value type, there is a section dedicated to it.
https://learn.microsoft.com/en-us...
Openhanded asked 3/6, 2020 at 4:31
2
Solved
I'm using Entity Framework 5 and have a generic repository, within which are several methods like the two Get() methods below:
public TEntity GetById(int id)
{
return DbSet.Find(id);
}
public TE...
Demote asked 15/1, 2013 at 19:39
1
I am trying to refactor my code using the IntelliJ idea extension called sonarLint.
In there, sonarLint suggests further modification like this picture below(I have marked the issue in red)
SonarLi...
Hamiltonian asked 10/12, 2021 at 15:38
1
I've stared to use spring's @EventListener annotation to create event handlers that handle my non-spring specific events. Initially everything went pretty well. I used a test to verify that I could...
3
Solved
I want to add typing to a Python function that takes in a type as an argument (actually, a subtype of a specific class), and return an instance of that type. Think a factory that takes in the speci...
Charron asked 25/5, 2021 at 9:41
7
Solved
Suppose we have an interface with a single generic method:
public interface IExtender
{
T GetValue<T>(string tag);
}
and a simple implementation A of it that returns instances of two diff...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.