{"id":488,"date":"2005-10-26T02:00:00","date_gmt":"2005-10-25T17:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2005-10-26-2.html"},"modified":"2005-10-26T02:00:00","modified_gmt":"2005-10-25T17:00:00","slug":"2005-10-26-2","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2005-10-26-2.html","title":{"rendered":"\u30af\u30e9\u30b9\u5b9a\u7fa9\u57fa\u672c(\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf, \u7d99\u627f, \u81ea\u5df1\u53c2\u7167, \u89aa\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057)"},"content":{"rendered":"<p>\n&#8211; initialize \u30e1\u30bd\u30c3\u30c9\u304c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u306a\u308b\u3002\n<\/p>\n<blockquote><p>class Foo<br \/>\n&nbsp;&nbsp;def initialize(arg)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;print &#8220;Hello, &#8221; + arg + &#8220;!&#8221;<br \/>\n&nbsp;&nbsp;end<br \/>\nend<br \/>\n&nbsp;<br \/>\nFoo.new(&#8220;world&#8221;)<br \/>\n# result:<br \/>\n#   Hello, world!\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n&#8211; \u7d99\u627f\u306f &#8220;<\"\u3002\u30b7\u30a7\u30eb\u3067\u4f7f\u3046\u3088\u3046\u306a\u53d6\u308a\u8fbc\u3080\u30a4\u30e1\u30fc\u30b8\n<\/p>\n<blockquote><p>class Parent<br \/>\nend<br \/>\n&nbsp;<br \/>\nclass Child < Parent<br \/>\nend\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n&#8211; \u89aa\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u306f\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067 super \u3068\u3059\u308b\u3002\n<\/p>\n<blockquote><p>class Parent<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;def foo(arg)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#8220;parent &#8220;, arg, &#8220;\\n&#8221;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;end<br \/>\nend<br \/>\n&nbsp;<br \/>\nclass Child < Parent<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;def foo(arg)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#8220;child\\n&#8221;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(arg)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;end<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<br \/>\nend<br \/>\n&nbsp;<br \/>\nChild.new.foo(&#8220;abc&#8221;)<br \/>\n#<br \/>\n# result:<br \/>\n# child<br \/>\n# parent abc<br \/>\n# \n<\/p><\/blockquote>\n<p>&#8211; \u30e1\u30bd\u30c3\u30c9\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u3067\u304d\u306a\u3044<br \/>\n\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u6700\u5f8c\u306e\u5b9a\u7fa9\u306e\u307f\u6709\u52b9\u306b\u306a\u308a\u3001\u305d\u308c\u4ee5\u5916\u306e\u547c\u3073\u51fa\u3057\u3067\u306f\u5f15\u6570\u306e\u6570\u304c\u9055\u3046\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3002\n<\/p>\n<blockquote><p>wrong number of arguments (1 for 0) (ArgumentError)\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n&#8211; \u81ea\u5df1\u53c2\u7167\u306f this \u3067\u306f\u306a\u304f self\n<\/p>\n<blockquote><p>class A<br \/>\n&nbsp;&nbsp;attr_reader :name  # \u5fc5\u9808<br \/>\n&nbsp;&nbsp;<br \/>\n&nbsp;&nbsp;def initialize<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;@name = &#8220;John&#8221;;<br \/>\n&nbsp;&nbsp;end<br \/>\n&nbsp;&nbsp;<br \/>\n&nbsp;&nbsp;def foo<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;print self.name<br \/>\n&nbsp;&nbsp;end<br \/>\nend<br \/>\n&nbsp;<br \/>\nA.new.foo<br \/>\n# <br \/>\n# result:<br \/>\n# John\n<\/p><\/blockquote>\n<p>self \u3067\u306e\u53c2\u7167\u306f\u30af\u30e9\u30b9\u5916\u90e8\u304b\u3089\u306e\u53c2\u7167\u3068\u540c\u7b49\u3068\u306a\u308b\u306e\u3067\u30a2\u30af\u30bb\u30b9\u5236\u9650\u306b\u6ce8\u610f!!<br \/>\n&nbsp;<br \/>\n&#8211; \u591a\u91cd\u7d99\u627f\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u5bfe\u3057\u3066\u306e\u307f\u53ef\u80fd<br \/>\n&lt;<a href=\"http:\/\/www.ruby-lang.org\/ja\/man\/?cmd=view;name=Module\">http:\/\/www.ruby-lang.org\/ja\/man\/?cmd=view;name=Module<\/a>><br \/>\ninclude \u3067\u7591\u4f3c\u7684\u306b\u5b9f\u88c5\u3059\u308b\u3002\n<\/p>\n<blockquote><p>class Parent<br \/>\nend<br \/>\n&nbsp;<br \/>\nmodule SubParent # module \u3067\u5ba3\u8a00\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f<br \/>\n&nbsp;&nbsp;def foo<br \/>\n&nbsp;&nbsp;end<br \/>\nend<br \/>\n&nbsp;<br \/>\nmodule SubParent2 # module \u3067\u5ba3\u8a00\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f<br \/>\n&nbsp;&nbsp;include SubParent # module -> module \u306e\u7d99\u627f<br \/>\n&nbsp;&nbsp;def woo<br \/>\n&nbsp;&nbsp;end<br \/>\nend<br \/>\n&nbsp;<br \/>\nclass Child < Parent   # class -> class \u306e\u7d99\u627f<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;include SubParent  # module -> class \u306e(\u591a\u91cd)\u7d99\u627f<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;include SubParent2 # module -> class \u306e(\u591a\u91cd)\u7d99\u627f<br \/>\nend\n<\/p><\/blockquote>\n<p>\u3061\u3083\u3093\u3068 SubParent, SubParent2 \u306e\u5b50\u3068\u3057\u3066\u8a8d\u8b58\u3055\u308c\u308b\u306e\u3067\u307e\u3041\u5b89\u5fc3\u3057\u3066\u4f7f\u3048\u308b\u3002<br \/>\n\u591a\u91cd\u306b\u3059\u308b\u306b\u306f\u89aa\u3092 module \u306b\u3057\u306a\u3044\u3068\u3060\u3081\u3063\u3066\u4e8b\u3067\u5236\u9650\u304c\u3042\u308b\u306e\u3067\u3001 Java \u3067\u3044\u3046\u3068\u3053\u308d\u306e interface \u306b\u8fd1\u3044\u4f7f\u3044\u65b9\u306b\u306a\u308b\u306e\u304b\u306a\u3002<br \/>\n&nbsp;<br \/>\n&#8211; \u59d4\u8b72 (delegate)<br \/>\n\u30c7\u30ea\u30b2\u30fc\u30c8\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u3063\u305f\u3002<br \/>\n&lt;<a href=\"http:\/\/www.ruby-lang.org\/ja\/man\/?cmd=view;name=delegate.rb\">http:\/\/www.ruby-lang.org\/ja\/man\/?cmd=view;name=delegate.rb<\/a>><br \/>\n\u3067\u3082\u30c7\u30ea\u30b2\u30fc\u30c8\u3057\u3066\u308b\u306e\u306b\u5ba3\u8a00\u6642\u70b9\u3067\u89aa\u30af\u30e9\u30b9\u306b\u306a\u3089\u306a\u3044\u3068\u3060\u3081\u3068\u304b\u5fae\u5999\u306a\u3088\u3046\u306a..<br \/>\ninclude delegate(Array)<br \/>\n\u307f\u305f\u3044\u306a\u4f7f\u3044\u65b9\u306a\u3089\u3044\u3044\u306e\u306b\u306a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8211; initialize \u30e1\u30bd\u30c3\u30c9\u304c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u306a\u308b\u3002 class Foo &nbsp;&nbsp;def initialize(arg) &nbsp;&nbsp;&nbsp;&nbsp;print &#038;# &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2005-10-26-2.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30af\u30e9\u30b9\u5b9a\u7fa9\u57fa\u672c(\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf, \u7d99\u627f, \u81ea\u5df1\u53c2\u7167, \u89aa\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[15],"class_list":["post-488","post","type-post","status-publish","format-standard","hentry","tag-ruby"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=488"}],"version-history":[{"count":0,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/488\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}