8. 現実は非情
5.5.0f3 Release Notes
• Scripting: Upgraded C# compiler to Mono 4.4. The new
compiler still targets C# 4 and .NET 3.5, but provides better
performance and many bug fixes.
10. クラスを2つ用意して実験
public class Garbage : MonoBehaviour
{
public void LogDisposed()
{
Debug.Log($"This is {(this.gameObject == null ? "" : "not ")}null.");
}
}
public class Disposer : MonoBehaviour
{
public GameObject Garbage;
public void Push()
{
var g = this.Garbage.GetComponent<Garbage>();
g.LogDisposed();
DestroyImmediate(g);
Debug.Log("Destory");
if (g == null)
{
Debug.Log("g is null.");
}
else
{
Debug.Log("g is not null.");
}
Debug.Log("null conditional");
g?.LogDisposed();
}
}
nullチェック
してるのに