From: "matz (Yukihiro Matsumoto)" Date: 2022-05-19T08:13:22+00:00 Subject: [ruby-core:108621] [Ruby master Feature#18618] no clobber def Issue #18618 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Closed See [#18742](https://bugs.ruby-lang.org/issues/18742#note-4) Matz. ---------------------------------------- Feature #18618: no clobber def https://bugs.ruby-lang.org/issues/18618#change-97657 * Author: ed_ (Ed Mangimelli) * Status: Closed * Priority: Normal ---------------------------------------- Sometimes I want to be certain I'm not clobbering/masking a method: ``` class Dog def bark 'bark!' end end class Poodle < Dog raise if method_defined? :bark def bark 'bow-wow' end end ``` I propose creating a shorthand. Maybe something like: ``` class Dog def bark 'bark!' end end class Poodle < Dog ncdef bark # "no clobber" def 'bow-wow' end end => # ``` This would be useful in scenarios where subclassing a class (or including a mixin) ***you don't own*** is common practice --for instance, subclassing `ApplicationRecord` for your model in Rails. I agree that `ncdef` is pretty ugly. Maybe `def!` -- https://bugs.ruby-lang.org/ Unsubscribe: