Recent

Author Topic: List of "magical" methods: where is documentation?  (Read 816 times)

XiJinping

  • New member
  • *
  • Posts: 9
List of "magical" methods: where is documentation?
« 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 =" ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: List of "magical" methods: where is documentation?
« Reply #1 on: September 12, 2019, 09:06:08 am »
You need to implement the Equal operator (in mode Delphi, in the other modes it's =) for your type. Also take into account how 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).

XiJinping

  • New member
  • *
  • Posts: 9
Re: List of "magical" methods: where is documentation?
« Reply #2 on: September 12, 2019, 09:49:03 am »
Thank you!

 

TinyPortal © 2005-2018