|
Wondering if someone could tell me the individual use case of these entity checking methods? I'm currently using IsZero to check an entity returned from a Map.GetRelation call to ensure that the entity wasn't previously deleted by another system and I'm wondering if there is a scenario that I'm missing where IsAlive would also be applicable in this use case? Or maybe IsAlive is there only check I should be doing? Any feedback would be much appreciated |
Replies: 1 comment 1 reply
|
Hi @KudaCoder, These two functions are quite different and serve different purposes. In your case, both would work, but What you should note is that the zero entity is the zero value of the var entity Entity // Uninitialized variable
entity := Entity{} // Explicit zero entityThe Hope this somewhat lengthy explanation clarifies you question. |
Hi @KudaCoder,
thank you for reaching out!
These two functions are quite different and serve different purposes. In your case, both would work, but
IsZeroshould be preferred. When an entity that is the target of a relation is deleted, all entities that have a relation "pointing" to it are moved into another table, with the "zero entity" as the new target. As the zero entity is never alive,IsAlivewould also work here, butIsZerois more clear.What you should note is that the zero entity is the zero value of the
Entitytype and is reserved for denoting "no entity", or an uninitializedEntityvariable. The world will never return the zero entity on entity creation, nor will any entity th…