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 Nancy Sinatra it:
Bang bang (my baby shot me down)
irb(main):003> ENV["FOO"] = "0"
=> "0"
irb(main):004> !!ENV["FOO"]
=> true
Would you expect this behavior?
@getajobmike the most intuitive env var APIs for Ruby users are the ones that only check for presence rather than contents (imho) but I know some do what you’re describing
Unfortunately if you want to provide a default value for the env var (say, on Heroku) then there is no way to force unset a default config.
This gem check if required env variables are present and its format using the .env and .env.sample files from Dotenv. - fastruby/dotenv_validator
@getajobmike Just today I noticed this is how it works. In a Rails controller `request.xhr? # => 0` when true.
I think JS is, infamously, the only language where you'd expect `!!"0" == true`.