Explorar o código

deleteField now returns Bool.

Nicolas Cannasse %!s(int64=19) %!d(string=hai) anos
pai
achega
6745cb8855
Modificáronse 1 ficheiros con 12 adicións e 4 borrados
  1. 12 4
      std/Reflect.hx

+ 12 - 4
std/Reflect.hx

@@ -365,13 +365,21 @@ class Reflect {
 	/**
 		Delete an object field.
 	**/
-	public static function deleteField( o : Dynamic, f : String ) {
+	public static function deleteField( o : Dynamic, f : String ) : Bool {
 		#if flash
-			untyped __delete__(o,f)
+			untyped {
+				if( this.hasOwnProperty.call(o,f) == null ) return false;
+				__delete__(o,f);
+				return true;
+			}
 		#else js
-			untyped delete(o[f])
+			untyped {
+				if( !hasField(o,f) ) return false;
+				untyped delete(o[f]);
+				return true;
+			}
 		#else neko
-			untyped __dollar__objremove(o,f.__s)
+			return untyped __dollar__objremove(o,f.__s)
 		#else error
 		#end
 			;