
Issue #19884 has been updated by p8 (Petrik de Heus). sawa (Tsuyoshi Sawada) wrote in #note-1:
Currently, you can do `ActiveRecord::Base.some_method rescue nil`
That would also rescue UndefinedMethodError, ArgumentError, and any error occuring in `some_method`.
Furthermore, the specification you are asking for is not clear. What Exception classes do you want `&.` to rescue?
`NameError`
You stated that you want `&.` to work on classes, but that does not make sense. If `ActiveRecord::Base` is not defined, it is not a class. How would Ruby know that it is (supposed to be) a class?
I have no idea how `&.` is currently implemented, but `defined?` also handles undefined classes. ---------------------------------------- Feature #19884: Make Safe Navigation Operator work on classes https://bugs.ruby-lang.org/issues/19884#change-104841 * Author: p8 (Petrik de Heus) * Status: Open * Priority: Normal ---------------------------------------- If a class might not be defined we need to add a conditional: ```ruby defined?(ActiveRecord::Base) && ActiveRecord::Base.some_method ``` It would be nice if we could use the Safe Navigation Operator instead. ```ruby ActiveRecord::Base&.some_method ``` -- https://bugs.ruby-lang.org/