次の方法があります。
float myMethod(MyObject[][] myList)
{
float a = 0;
if (myListProcessingMethod(myList?.Where(x => x.mySatisfiedCondition()).ToList()))
{
a = 5;
}
return a;
}
bool myListProcessingMethod(List<MyObject[]> myList)
{
bool isSuccess = false;
if (myList.Any())
{
isSuccess = true;
}
return isSuccess;
}
私はこの条件を考えます:
if (myListProcessingMethod(myList?.Where(x => x.mySatisfiedCondition()).ToList()))
条件を次のようにリファクタリングします。
if (myList?.Length != 0)
{
if (myListProcessingMethod(myList.Where(x => x.mySatisfiedCondition()).ToList()))
{
a = 5;
}
}
この2つの条件は同等ですか?従来の方法で最初の NullConditionOperator に相当する条件は何ですか? NullConditionalOperator を使用した 2 番目の従来のチェックと同等の条件は何ですか?