Color Specification class in c# is giving me error : The non-generic type-or-method 'identifier' cannot be used with type arguments

i am learning design patterns in c# language, so i wrote class which filters the products by color(enum). I used interfaces Ispecification and Ifilter which take T as generic type. here is the code i wrote public interface ISpecification<T> { public bool IsSatisfied(T t); } public interface IFilter<T> { IEnumerable<T> Filter(IEnumerable<T> items, ISpecification<T> specification); }… Read More Color Specification class in c# is giving me error : The non-generic type-or-method 'identifier' cannot be used with type arguments

Swift Property Wrappers-Initialization fails with 'cannot convert value of type 'Double' to expected argument type'

I’ve made myself a playground-example to become familar with Property Wrappers. Following code: import Foundation @propertyWrapper struct Price { private var price: Double init() { self.price = 0.0 } var wrappedValue: Double { get { return self.price } set { if newValue < 0.0 { self.price = 0.0 } else if newValue > 10_000 {… Read More Swift Property Wrappers-Initialization fails with 'cannot convert value of type 'Double' to expected argument type'

Can some one explain me the this regex pattern in python? re.findall("[a-zA-Z*,*\-!*.]"

re.findall("[a-zA-Z*,*\-!*.]" This regular expression checks for valid letters, ".", "-", "-", "!" in a word. I understood the first part [a-zA-Z] Can someone please explain this? [*,*\-!*.] >Solution : You can use the online tool regex101 to understand your regex and test it, for example, here is the explanation for this regex: Match a single… Read More Can some one explain me the this regex pattern in python? re.findall("[a-zA-Z*,*\-!*.]"

How would i make a pascal triangle that keeps adding another star until it hits the end limit

so I have 3 inputs a,b,c ex 4, 7, 1 ++++ +++++ ++++++ +++++++ its supposed to look like this, it starts at 4 stars and keeps adding another star c times until it reaches 7 how would I code this Im very confused this is what I have so far #include <iostream> #include <iomanip>… Read More How would i make a pascal triangle that keeps adding another star until it hits the end limit

Python Singleton objects with the same attribute

I want Python to return the same object when the instances are created with the similar attributes. class Session: def __init__(self, id): self.id = id … … session1 = Session(1) print(id(session1)) # 1111 session1a = Session(1) print(id(session11)) # 1111 session2 = Session(2) print(id(session1)) # 2222 You can see above that I want session1 and session1a… Read More Python Singleton objects with the same attribute

Why do many Win32 Strucs contain their size as a member

This is not strictly a programming question but more of a design question. Working with some strucs from the WinAPI I noticed that many of them contain a field called dwSize that simpally stores their size e.g THREADENTRY32 or BLUETOOTH_DEVICE_SEARCH_PARAMS typedef struct tagTHREADENTRY32 { DWORD dwSize; DWORD cntUsage; DWORD th32ThreadID; DWORD th32OwnerProcessID; LONG tpBasePri; LONG… Read More Why do many Win32 Strucs contain their size as a member