我在stackoverflow中查看是否將null合併運算符放在訪問器方法中有任何性能影響。 前:我 private Uri _Url;
public Uri Url
{
get
{
return _Url = _Url ?? new Uri(Utilities.GenerateUri());
}
}
甚至不知道如果語法是正確的,但是當我調試,私
我有一個代碼 void Foo()
{
auto index = currentIndex();
if (index.isValid())
index.doSomething();
}
另一種選擇 void Foo()
{
if (currentIndex().isValid())
currentIndex().doSomething
我的IDE(IntelliJ IDEA的)告訴我,我不得不刪除這個括號的選項,如果聲明: if (objectIsOfTypeFoo) {
if (objectOfTypeFooIsShared) {
// do something with Object of type Foo knowing that it's shared...
} else {