Can I detect whether I've been given a new object as a parameter?

前端 未结 9 675
日久生厌
日久生厌 2021-01-18 01:31

Short Version

For those who don\'t have the time to read my reasoning for this question below:

Is there any way to enforce a policy of "new obje

9条回答
  •  遇见更好的自我
    2021-01-18 02:14

    As a possible partial solution if you only wanted one of an object to be consumed by a method maybe you could look at a Singleton. In this way the method in question could not create another instance if it existed already.

提交回复
热议问题