Can an object remove itself? How?

前端 未结 5 862
我在风中等你
我在风中等你 2021-01-17 15:31

I\'m trying to write a simple ball game, and there\'s several turns (ie., ball lives). The ball \"dies\" when it passes the bottom border of the screen. What I have so far w

5条回答
  •  北恋
    北恋 (楼主)
    2021-01-17 16:18

    No, objects cannot suicide. Any reference of itself is just a reference.

    To "clear" the object within itself one would just clear all instance variables.

    To "clear" the object outside itself one would set the variable equal to null.

提交回复
热议问题