expr
expr copied to clipboard
Cannot use T as type int in array
I have read the document several times but still can't understand where the usage issues are. Could you please help take a look?
https://go.dev/play/p/LwYtRm2NuXM
Looks like #632
Yes, this is by design.
type Platform int
In internal golang representation, Platform is different from the int. Although Expr does automative type conversions for ints, in this case you will need to case to int explisitly:
int(platform) in [1, 2]
Explanation about why Golang behaves this way: https://github.com/expr-lang/expr/issues/632#issuecomment-2069038213