From: "sawa (Tsuyoshi Sawada) via ruby-core" Date: 2023-10-07T11:37:07+00:00 Subject: [ruby-core:114970] [Ruby master Feature#19884] Make Safe Navigation Operator work on classes Issue #19884 has been updated by sawa (Tsuyoshi Sawada). p8 (Petrik de Heus) wrote in #note-5: > > Furthermore, the specification you are asking for is not clear. What Exception classes do you want `&.` to rescue? > > `NameError` Then you should edit and write that in the description. > `defined?` also handles undefined classes. Can you show an example of that? ---------------------------------------- Feature #19884: Make Safe Navigation Operator work on classes https://bugs.ruby-lang.org/issues/19884#change-104842 * 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/ ______________________________________________ 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/postorius/lists/ruby-core.ml.ruby-lang.org/