Issue #13551 has been updated by shevegen (Robert A. Heiler).


Martin showed this example:

> class Array
>   class << self
>     alias :my_new :new
>   end

Ruby allows this flexibility, this is true. This is also great, we
love it.

But when you use this code and want to distribute it, it is more
cumbersome. And not everyone likes to have modifications that
are non-standard ruby in their code.

I understand that the ruby team wants to be conservative and not
proliferate with lots of extra methods that have only a special
case (say active* gems), but to me I also completely understand
Joshua Stowers here - if possible it is MUCH, much better when
it would be in main ruby. So that everyone could use it.

- I may use it if it is in ruby core/stdlib.
- I may use duck patching (sometimes people use the monkey rather
than the duck) for my local code.
- But it is VERY unlikely that I would modify a core class of
ruby like this AND distribute my code to other people too. I
just consider it too cumbersome (and refinements, while the
idea is ok, I never really liked the syntax... and it felt
awkward... but this is for another discussion, lots of time
towards ruby 3.x I hope).

----------------------------------------
Feature #13551: Add a method to alias class methods
https://bugs.ruby-lang.org/issues/13551#change-65007

* Author: JustJosh (Joshua Stowers)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
There doesn't seem to be an intuitive way to alias class methods.

Perhaps we can add a method such as 

~~~ ruby
alias_class_method :new_name, :old_name
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>