Project1

标题: Input内用alias的问题 [打印本页]

作者: Wind2010    时间: 2012-3-25 15:48
标题: Input内用alias的问题
  1. module Input
  2.   alias self.new_press? self.press?
  3.   alias self.new_trigger? self.trigger?
  4.   alias self.new_repeat? self.repeat?
  5.   def self.press?(input)
  6.     return self.new_press?(input)
  7.   end
  8.   def self.trigger?(input)
  9.     return self.new_trigger?(input)
  10.   end
  11.   def self.repeat?(input)
  12.     return self.new_repeat?(input)
  13.   end
  14. end
复制代码
嗯就是这样,带有self.的定义不能用alias来重定义?dsu_plus_rewardpost_czw
作者: R-零    时间: 2012-4-3 11:27
给方法或全局变量添加别名。可以给方法名指定一个标识符或 Symbol(不能写 obj.method 这样的表达式)。 alias 的参数不会被计算。


文档里是这么写的,如果是想要那个效果的话,可以用全键盘调用啊
作者: end55rpg    时间: 2012-4-3 12:18
我不想写了,看我一个帖子发了一个显示消息的脚本,重定义了Graphics的update看看吧。点我图进空间/主题里面
作者: R-零    时间: 2012-4-3 13:53
本帖最后由 R-零 于 2012-4-3 13:56 编辑

ls的意思是method("??")这个
东西


类似于这样

RUBY 代码复制
  1. module Input
  2.   a = method("press?")
  3.   def self.press?(input)
  4.     a
  5.     p "!!"
  6.     return
  7.   end
  8. end
���
作者: fux2    时间: 2012-4-3 16:52
  1. class << Input
  2.   alias n_press press?
  3.   def press?(input)
  4.     p "fux2"
  5.     n_press(input)
  6.   end
  7. end
复制代码

作者: 忧雪の伤    时间: 2012-4-3 17:01
本帖最后由 忧雪の伤 于 2012-4-3 17:42 编辑

alias 加上 self. 是何用意?……
直接 alias another_press? press? 难道不行?


用特殊对象 class <<
作者: end55rpg    时间: 2012-4-3 17:38
R-零 发表于 2012-4-3 13:53
ls的意思是method("??")这个
东西

  1. module Input
  2.   alias self.new_press? self.press?
  3.   alias self.new_trigger? self.trigger?
  4.   alias self.new_repeat? self.repeat?
  5.   def self.press?(input)
  6.     return self.new_press?(input)
  7.   end
  8.   def self.trigger?(input)
  9.     return self.new_trigger?(input)
  10.   end
  11.   def self.repeat?(input)
  12.     return self.new_repeat?(input)
  13.   end
  14. end
复制代码
嗯就是这样,带有self.的定义不能用alias来重定义?dsu_plus_rewardpost_czw



没错




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1