Reputation: 7619
I'm getting conditions in an string.
For example: String conditions = "gender == 1 && gender == 3";
I want to convert it into If Conditional statement.
like if(gender == 1 && gender == 3) { }
How can I parse that string ?
Upvotes: 3
Views: 1945
Reputation: 1178
You can use function_tree package to convert string to expression.
String conditions = "gender == 1 && gender == 3";
if(conditions.interpret()) { }
Upvotes: 1