Why does Assigned return true for uninitialized variables?

后端 未结 3 1587
一向
一向 2021-01-18 12:21

I read many posts on forum about pointers, Assigned function, Free function, FreeAndNil function, etc... I already know Free function

3条回答
  •  误落风尘
    2021-01-18 12:46

    Because when creating a pointer, it cames with whatever garbage value was in that memory position. If you want to write NIL in it, it takes some CPU cycles, and I think it's not automatically done by Delphi because you may want something faster. In your example, why assign NIL to a variable, if soon afterwards you're going to put another value in it?

提交回复
热议问题