Hey guys
Hey guys,
I have a doubt, I need to check whether a queue contains a item, there is no generic constraints about its type, thus the generic parameter T can be a reference type (class) or a value type (record). The first thing that I need to check is whether T is a class for allow nil values (The parameter Item can be nil, once it is a reference type), the code must work as well as possible with records. Is there a straightforward way to achieve this other than using TValue as in the image below?
Thanks in advance.
Your indenting is misleading - the else belongs to the second if. Also the equalitycomparer already handles nil values (see System.Generics.Defaults.Equals_Class f.i.)
ReplyDeleteStefan Glienke You are correct :D I have fixed the method as you suggested, many thanks :D The result can be seen at https://github.com/horaciojcfilho/Kelloggi/blob/nightly/Kelloggi/Kelloggi.Collections.Generic.pas#L182-L198 :D
ReplyDelete