mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +02:00
Nullable fixes for ??
This commit is contained in:
parent
8b17718fed
commit
ad11792940
2 changed files with 14 additions and 1 deletions
|
@ -53,6 +53,14 @@ namespace System
|
||||||
{
|
{
|
||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetValue(ref T outValue)
|
||||||
|
{
|
||||||
|
if (!mHasValue)
|
||||||
|
return false;
|
||||||
|
outValue = mValue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public T GetValueOrDefault(T defaultmValue)
|
public T GetValueOrDefault(T defaultmValue)
|
||||||
{
|
{
|
||||||
|
@ -383,6 +391,11 @@ namespace System
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
public static T operator??(Nullable<T> lhs, T rhs)
|
||||||
|
{
|
||||||
|
return (lhs.mHasValue) ? lhs.mValue : rhs;
|
||||||
|
}
|
||||||
|
|
||||||
public static TResult? operator??<TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult = operator TOther ?? T where TResult : struct
|
public static TResult? operator??<TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult = operator TOther ?? T where TResult : struct
|
||||||
{
|
{
|
||||||
if (!rhs.mHasValue) return null;
|
if (!rhs.mHasValue) return null;
|
||||||
|
|
|
@ -1559,7 +1559,7 @@ const char* Beefy::BfGetOpName(BfBinaryOp binOp)
|
||||||
case BfBinaryOp_Compare: return "<=>";
|
case BfBinaryOp_Compare: return "<=>";
|
||||||
case BfBinaryOp_ConditionalAnd: return "&&";
|
case BfBinaryOp_ConditionalAnd: return "&&";
|
||||||
case BfBinaryOp_ConditionalOr: return "||";
|
case BfBinaryOp_ConditionalOr: return "||";
|
||||||
case BfBinaryOp_NullCoalesce: return "&&";
|
case BfBinaryOp_NullCoalesce: return "??";
|
||||||
case BfBinaryOp_Is: return "is";
|
case BfBinaryOp_Is: return "is";
|
||||||
case BfBinaryOp_As: return "as";
|
case BfBinaryOp_As: return "as";
|
||||||
default: return "???";
|
default: return "???";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue