-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flipper.register
should match any truthy value, not just true
#110
Comments
Hmm. That is annoying. I can see thinking that would work.
I prefer explicit and safety. It is safer to accidentally or confusingly keep something disabled than to accidentally or confusingly enable a feature. For example, in this case, though confusing that no one was enabled, there was no harm (other than your time spent confused about this and researching). The opposite is not true though. If a truthy-ish value (0, etc.) snuck in and enabled something for a bunch of people without one expecting that to happen, it could be really bad. That said, I can't really think of a good example of where truthy could burn (other than perhaps 0), so maybe I should change this. What are your thoughts? Still feeling truthy would be better? |
I still do. Even I do see your point about accidentally enabling a flipper being worse than the alternative, but I don't think it'll happen - not many methods return zero in a context where it would matter here. The main one I can think of is checking the size of a collection, and even then people are more likely to use a method which returns an actual boolean:
But that's not idiomatic ruby, I think people are more likely to use one of: |
If you decide not to make a change here, then the documentation for |
I have a branch locally started to change. Hoping to finish it soon, but have some bigger things on my todo list right now. Feel free to whip something together if you have time. |
Aside from the comment I made on the commit, that looks like exactly the right change for us :) |
We recently wrote something like the following, hoping to set a generic group for flipper usage.
It didn't work, because
String#=~
returns an integer (the position of the match in the string) rather than true/false. Flipper groups only respond if theregister
block explicitly returnstrue
.This seems a bit unrubyish, so I wondered if there was a specific reason that only
true
was allowed rather than (IMO) the more usual convention of any truthy value?The text was updated successfully, but these errors were encountered: