Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haxe: How to check if a variable is a function

Tags:

types

haxe

I would like to see if a Dynamic variable in Haxe is a Function.

Using Std.is(v, Function) does not work as Function is not a recognized key word for types.

I tried fooling around with $type(v) but it doesn't seem to actually return a string. Sys.println($type(v)); does output <function> but it doesn't seem like I can work with it.

I also tried to use Std.is with typedef but no luck as typedefs are not variables.

TDLR: I want a function that takes a variable and outputs a boolean based on if it is a function.

like image 952
dmcblue Avatar asked Oct 25 '25 01:10

dmcblue


1 Answers

You're looking for Reflect.isFunction().

like image 182
Gama11 Avatar answered Oct 27 '25 00:10

Gama11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!