Lazarus

Free Pascal => Beginners => Topic started by: XiJinping on September 12, 2019, 07:34:51 am

Title: List of "magical" methods: where is documentation?
Post by: XiJinping on September 12, 2019, 07:34:51 am
When I use TFPGList or similar, I need to implement method Equal. So, I have 2 questions here: is this method a part of some interface (something like `IEquable`?) and where I can find documentation about all such "magical" methods/interfaces?

PS. I call it magical because it looks to me like "__eq__" in Python. But they are not related to operators, right? I mean Equal(...) is not magically turn into "operator =" ?
Title: Re: List of "magical" methods: where is documentation?
Post by: PascalDragon on September 12, 2019, 09:06:08 am
You need to implement the Equal (https://www.freepascal.org/docs-html/current/ref/refse103.html#x212-23400015.5) operator (in mode Delphi, in the other modes it's =) for your type. Also take into account how (https://www.freepascal.org/docs-html/current/ref/refse57.html#x116-1380008.9) operator overloading behaves in regards to generics (meaning that you can't use a global operator overload, but it needs to be a part of the type).
Title: Re: List of "magical" methods: where is documentation?
Post by: XiJinping on September 12, 2019, 09:49:03 am
Thank you!