Null-coalescing operator and lambda expression

后端 未结 2 1223
Happy的楠姐
Happy的楠姐 2020-12-10 14:02

take a look at the following code I attempted to write inside a constructor:

private Predicate _isValid;

//...

Predicate isVali         


        
2条回答
  •  攒了一身酷
    2020-12-10 14:47

    this._isValid = isValid ?? (s => true);
    

    Will work :)

    It parsed it this way:

    this._isValid = (isValid ?? s) => true;
    

    which does not make any sense.

提交回复
热议问题