2010å¹´01æ27æ¥09:23 Ruby Rubyã®method_missingã使ã£ã¦é»éè¡ãå®è£ ãã Rubyã«ã¯ã¡ã½ããæ¢ç´¢ã®æå¾ã«å¼ã°ããï¼ã¤ã¾ããã¡ã½ãããè¦ã¤ãããªãã¨ãã«å¼ã°ããï¼ããã¯çãªã¡ã½ããã¨ã㦠method_missing ã¨ããã¡ã½ãããããã¾ãããããä¸æã«å©ç¨ãããã¨ã§é»éè¡çãªã³ã¼ããæ¸ãã¦ãã£ãããã§ãï½ #!/usr/bin/ruby module Sasata299 # é©å½ãªã¢ã¸ã¥ã¼ã«ãå®ç¾© def hoge(num) return num * 2 end def fuga(num) return num + '299' end end def method_missing(action, *args) if action.to_s =~ /(.+)_(.+)/ eval "include #{$1.capitalize}" __send__ $
{{#tags}}- {{label}}
{{/tags}}