开发者

haxe: Indirect property referencing

开发者 https://www.devze.com 2023-01-18 15:59 出处:网络
I might be missing something obvious, but how do I reference a property indirectly? E.g in javascript it would be:

I might be missing something obvious, but how do I reference a property indirectly? E.g in javascript it would be:

 if(propName in obj) return obj[propName];

How to say the same in开发者_如何学Python haxe? The object in question is Dynamic<String>, flash.display.LoaderInfo.parameters to be specific.

Many thanks.


if(Reflect.hasField(obj, propName)) return Reflect.field(obj, propName);

Althought it seems more code, the generated output is basically the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消