From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2024-12-14T05:29:17+00:00 Subject: [ruby-core:120237] [Ruby master Feature#20882] Provide Boolean(...) Issue #20882 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Rejected I don't think it works well in the Ruby ecosystem. Rejected (as previous proposals). Matz. ---------------------------------------- Feature #20882: Provide Boolean(...) https://bugs.ruby-lang.org/issues/20882#change-111005 * Author: getajobmike (Mike Perham) * Status: Rejected ---------------------------------------- Ruby provides Integer(...) and Float(...) global methods to coerce values. Is there a similar method for Booleans? I'd like to do something like: ``` # ENV["SOME_FEATURE"] is unset Boolean(ENV["SOME_FEATURE"]) # => false # ENV["SOME_FEATURE"] is unset, but allow a default? Boolean(ENV["SOME_FEATURE"], true) # => true # explicitly disable ENV["SOME_FEATURE"] = "0" Boolean(ENV["SOME_FEATURE"], true) # => false # explicitly enable ENV["SOME_FEATURE"] = "1" Boolean(ENV["SOME_FEATURE"]) # => true ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/