diff --git a/BeefLibs/corlib/src/Nullable.bf b/BeefLibs/corlib/src/Nullable.bf index c2975345..769076a3 100644 --- a/BeefLibs/corlib/src/Nullable.bf +++ b/BeefLibs/corlib/src/Nullable.bf @@ -53,6 +53,14 @@ namespace System { return mValue; } + + public bool TryGetValue(ref T outValue) + { + if (!mHasValue) + return false; + outValue = mValue; + return true; + } public T GetValueOrDefault(T defaultmValue) { @@ -383,6 +391,11 @@ namespace System // + public static T operator??(Nullable lhs, T rhs) + { + return (lhs.mHasValue) ? lhs.mValue : rhs; + } + public static TResult? operator??(TOther lhs, Nullable rhs) where TResult = operator TOther ?? T where TResult : struct { if (!rhs.mHasValue) return null; diff --git a/IDEHelper/Compiler/BfAst.cpp b/IDEHelper/Compiler/BfAst.cpp index df7457f2..bb1fde95 100644 --- a/IDEHelper/Compiler/BfAst.cpp +++ b/IDEHelper/Compiler/BfAst.cpp @@ -1559,7 +1559,7 @@ const char* Beefy::BfGetOpName(BfBinaryOp binOp) case BfBinaryOp_Compare: return "<=>"; case BfBinaryOp_ConditionalAnd: return "&&"; case BfBinaryOp_ConditionalOr: return "||"; - case BfBinaryOp_NullCoalesce: return "&&"; + case BfBinaryOp_NullCoalesce: return "??"; case BfBinaryOp_Is: return "is"; case BfBinaryOp_As: return "as"; default: return "???";