Alternative to instanceof?

后端 未结 4 674
清歌不尽
清歌不尽 2021-01-07 07:17

I\'ve heard that it is bad design to use instanceof or equivalent (http://www.javapractices.com/topic/TopicAction.do?Id=31, when should we use instanceof and when not) which

4条回答
  •  梦谈多话
    2021-01-07 07:43

    Well, have you considered iterating over all of the tanks to see if they're in range instead of all of the entities in range to see if they're tanks? Seems like it would save you a lot of time on both iteration and instanceof calls...

提交回复
热议问题