Ruby has Integer(...) and Float(...), but does it have Boolean(…) for things like:
Boolean(ENV[“SOME_FLAG”])
What's the Ruby idiom here?
Ruby has Integer(...) and Float(...), but does it have Boolean(…) for things like:
Boolean(ENV[“SOME_FLAG”])
What's the Ruby idiom here?
@getajobmike I have always used ENV["SOME_FLAG”] == "true”
I am definitely Team I Don’t Like 78 Forms of Boolean Representation, so anything other than the string "true" is considered false to me.
But I would love to see a Boolean data type and coercion method to address this issue from stdlib
["1", "y", "yes", "true"].include?(ENV["FLAG"].to_s.downcase ) 🙃
And of course for the opposite:
["0", "n", "no", "false"].include?(ENV["FLAG"].to_s.downcase)