簡體   English   中英

如何在haxe中檢測來電者?

[英]How to detect caller in haxe?

我正在設置一個屬性,我需要知道誰設置了屬性值? haxe 3有可能嗎?

另外,我可以知道誰在函數內部調用函數嗎?

看看PosInfos 你這樣使用它:

public static function add(a:Int, b:Int, ?pos:PosInfos) {
    trace( 'Called from ${pos.className}');
    trace( 'Called from ${pos.methodName}');
    trace( 'Called from ${pos.fileName}');
    trace( 'Called from ${pos.lineNumber}');
    return a+b;
}

add( 1, 1 ); // "pos" will automatically be filled in by compiler

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM