LoginSignup
1
0

More than 3 years have passed since last update.

【Ruby/Rails】aliasを使う。rubocopに怒られない方法で!

Posted at

環境

問い

aliasを使うべきかalias_methodを使うべきか、symbolで定義すべきかしないべきか。

これが答えだ!

aliasを使い、symbol使わない

インスタンスメソッド

  def existing_method
    ...
  end

  alias alias_method existing_method

クラスメソッド

  def self.existing_method
    ...
  end

  class << self
    alias alias_method existing_method
  end
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0