当前位置:网站首页>Check if this is null - checking if this is null

Check if this is null - checking if this is null

2022-07-05 00:49:00 Superior virtue and weak water

problem :

Does it ever make sense to check if this is null? Check this Whether it is empty or meaningful ?

Say I have a class with a method; Suppose I have a class with methods ;inside that method, I check this == NULL , and if it is, return an error code. In this method , I check this == NULL , If it is , The error code is returned .

If this is null, then that means the object is deleted. If this It's empty. , Then this means that the object is deleted .Is the method even able to return anything? Can this method even return anything ?

Update: I forgot to mention that the method can be called from multiple threads and it may cause the object to be deleted while another thread is inside the method. to update : I forgot to mention that this method can be called from multiple threads , It may cause the object to be deleted , Another thread is inside the method .


Solution :

Reference resources : https://stackoom.com/en/question/7ji1
原网站

版权声明
本文为[Superior virtue and weak water]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141110208943.html