6

Idiosyncratic Ruby: Warning: The Experiment

 3 years ago
source link: https://idiosyncratic-ruby.com/67-warning-the-experiment.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Warning: The Experiment

Ruby's Warning module learned some new tricks in Ruby 2.7:

Support for muting different categories of compile warnings has been introduced. This is a mechanism on top of the warning level reflected by the $VERBOSE variable.

You can now silence deprecation warnings: These are aspects of the language which will be removed or changed in a future version of Ruby. One example is the infamous: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call

It is also possible to mute experimental features warnings: These are new features of Ruby, which might not have a stable API yet, like the new pattern matching

Per Ruby

Warning[:experimental] = false
Warning[:deprecated] = false

Per CLI

$ ruby -W:no-deprecated
$ ruby -W:no-experimental

Per ENV Variable

$ RUBYOPT="-W:no-deprecated" ruby
$ RUBYOPT="-W:no-experimental" ruby

Also See

More Idiosyncratic Ruby


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK