Brian Fiete 1 éve
szülő
commit
c58f327136
1 módosított fájl, 11 hozzáadás és 0 törlés
  1. 11 0
      BeefLibs/corlib/src/Variant.bf

+ 11 - 0
BeefLibs/corlib/src/Variant.bf

@@ -65,6 +65,8 @@ namespace System
 				}
 				if (mStructType <= 1)
 				{
+					if (mData == 0)
+						return null;
 					return Internal.UnsafeCastToObject((void*)mData).GetType();
 				}
 				return (Type)Internal.UnsafeCastToObject((void*)(mStructType & ~3));
@@ -343,6 +345,15 @@ namespace System
 				return *(T*)(void*)mData;
 		}
 
+		public bool TryGet<T>(out T value)
+		{
+			value = default;
+			if (VariantType != typeof(T))
+				return false;
+			value = Get<T>();
+			return true;
+		}
+
 		public Result<Object> GetBoxed()
 		{
 			if (IsObject)