Ruby alias 与 alias_method

grubby · August 19, 2013 · Last by ptmagic replied at August 20, 2013 · 2886 hits
class A
  def a
    puts 'a'
  end
end

A.instance_eval do 
  alias :b :a  #出错undefined method `a' for class `Class' (NameError)
end

A.class_eval do 
  alias :b :a
end

A.instance_eval do 
  alias_method :b, :a
end

A.class_eval do 
  alias :b :a
end

什么情况,为什么找不到方法啊,其他的都没有问题呢?

@xds2000 Hi,openshift 有源码部署的资料吗?有的话,能发我看看吗?谢谢

@ptmagic 还是那句话:“其实,搜一下就搞定了。”

http://openshift.github.io/documentation/

#3 楼 @xds2000 哈哈,找到了,谢了哈

You need to Sign in before reply, if you don't have an account, please Sign up first.