Browse Source

Merge pull request #1947 from Justinfront/development

Development
Simon Krajewski 12 năm trước cách đây
mục cha
commit
7b16b39fdb
2 tập tin đã thay đổi với 9 bổ sung1 xóa
  1. 4 0
      std/cs/_std/Std.hx
  2. 5 1
      std/java/_std/Std.hx

+ 4 - 0
std/cs/_std/Std.hx

@@ -234,6 +234,10 @@ import cs.internal.Exceptions;
 		}
 	}
 
+	public static function instance<T>( v : { }, c : Class<T> ) : T {
+		return Std.is(v, c) ? cast v : null;
+	}
+
 	public static function random( x : Int ) : Int {
 		if (x <= 0) return 0;
 		return untyped Math.rand.Next(x);

+ 5 - 1
std/java/_std/Std.hx

@@ -237,7 +237,11 @@ import java.internal.Exceptions;
 	public static function parseFloat( x : String ) : Float {
 		return 0.0;
 	}
-
+	
+	public static function instance<T>( v : { }, c : Class<T> ) : T {
+		return Std.is(v, c) ? cast v : null;
+	}
+	
 	public static function random( x : Int ) : Int {
 		if (x <= 0) return 0;
 		return Std.int(Math.random() * x);