三元運算符有一個簡寫,即速記三元運算符是否進行多重計算?
var = exp ?: exp2
我知道它在PHP。其他語言也可能挑選它。 C#具有類似的功能(針對此問題的上下文) - ??
。
當條件通過時,是表達式再次求值,或者在結果存儲在某處?
三元運算符有一個簡寫,即速記三元運算符是否進行多重計算?
var = exp ?: exp2
我知道它在PHP。其他語言也可能挑選它。 C#具有類似的功能(針對此問題的上下文) - ??
。
當條件通過時,是表達式再次求值,或者在結果存儲在某處?
http://msdn.microsoft.com/en-us/library/ms173224.aspx
The ?? operator is called the null-coalescing operator and is used to define a default value for nullable value types or reference types. It returns the left-hand operand if the operand is not null; otherwise it returns the right operand.
它存儲,不計算兩次。
等等,那麼問題是什麼語言? – domsson 2017-07-24 13:20:05