This message contains interactive elements.
# announcements
s
This message contains interactive elements.
This condition is giving false value -
Copy code
if (growthBook.isOn("discount")) {}
even though similar features are giving enabled response.
Hi all, just observed that even though above condition is false, i am getting the feature value for a user id.. it means only the condition part is not working..any idea ?
Also, when toggling to disabled i am getting default value..
h
All of this seems like the expected behavior. What is the configuration for
discount
?
s
Here is the configuration
But, isOn should give me true value right ?
this way in future i wont be able to disable my feature.
h
Yeah, it looks like in this case
isOn
should always return true, since the value is always non-zero.
s
Yes
Any idea ?
h
but when you call
growthBook.getFeatureValue("discount", 0);
in the same place it returns an Integer of 10 or 20?
s
Yes
h
If it works for your other features, I'd have to think there's some difference in the configuration that is calling this. Very hard for me to know, but I can take a deeper look in a bit.
s
Sure, please let me know if i can provide any info
b
i just looked into this and it looks like there's a bug in the
FeatureResult#isOn
method. it has to do with all the numeric types in java (double vs. float vs. integer, etc.). here's a workaround until we get this fixed:
Copy code
FeatureResult<Float> donutPriceFeatureResult = growthBook.evalFeature("donut_price", Float.class);
System.out.printf("Donut price feature result %s\n", donutPriceFeatureResult);
System.out.printf("Donut price feature is on %s\n", donutPriceFeatureResult.isOn()); // there is a bug here (this is the one you found)
System.out.printf("Donut price feature is on %s\n", donutPrice != 0.0f); // workaround
s
Thanks a lot @better-magician-65629 @helpful-application-7107 for helping me out !
b
FYI a fix for this bug is available in 0.7.1
🙌 1