{"id":5771,"date":"2020-08-07T09:27:35","date_gmt":"2020-08-07T00:27:35","guid":{"rendered":"https:\/\/yumishin.com\/?p=5771"},"modified":"2020-08-07T09:28:13","modified_gmt":"2020-08-07T00:28:13","slug":"ruby-gold-5","status":"publish","type":"post","link":"https:\/\/yumishin.com\/?p=5771","title":{"rendered":"RubyGold\u3067\u5b9f\u969b\u306b\u51fa\u984c\u3055\u308c\u305f\u554f\u984c\uff08\u3046\u308d\u899a\u3048\uff09"},"content":{"rendered":"<p>\u3069\u3046\u3082\u3001RubyGold\u306b\u5148\u65e5\u5408\u683c\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u3055\u3066\u4eca\u56de\u306f\u5b9f\u969b\u306b\u51fa\u984c\u3055\u308c\u305f\u554f\u984c\u3092\u3046\u308d\u899a\u3048\u3067\u3059\u304c\u3001\u7c21\u5358\u306b\u307e\u3068\u3081\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2 id=\"i-0\">Gold\u3067\u51fa\u984c\u3055\u308c\u305f\u554f\u984c\u3067\u60a9\u307e\u3057\u304b\u3063\u305f\u3082\u306e<\/h2>\n<h3 id=\"i-1\">protected\u306e\u4f7f\u3044\u65b9<\/h3>\n<p>protected\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u306f\u51fa\u307e\u3057\u305f\u3002private\u3068protected\u3092\u9078\u3070\u305b\u308b\u554f\u984c\u3067\u3059\u3002<\/p>\n<p>\u78ba\u304b\u8a08\u7b97\u554f\u984c\u306e\u3088\u3046\u306a\u5f62\u3067\u3001\u5185\u90e8\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b\u305f\u3081\u306bprotected\u3092\u9078\u3070\u305b\u3001private\u306fTypeError\u3092\u767a\u751f\u3055\u305b\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u5f62\u3060\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>\u4ee5\u4e0b\u9078\u629e\u80a2\u306e\u4e2d\u3067<span style=\"color: #ff0000;\">__(1)__\u306b\u5f53\u3066\u306f\u307e\u3089\u306a\u3044\u3082\u306e\u306f\u306a\u3093\u3067\u3059\u304b\uff1f<\/span><\/p>\n<p>&nbsp;<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30b3\u30fc\u30c9<\/span><\/p>\n<pre><code>class BaseClass\n  private\n\n  def greet\n    puts \"Hello World!\"\n  end\nend\n\nclass ChildClass &lt; BaseClass\n  __(1)__\nend\n\n\nChildClass.new.greet\n\n[Execution Result]\nHello World!<\/code><\/pre>\n<\/div>\n<p><em>A:<\/em><code>public :greet<br \/>\n<\/code><\/p>\n<p><em>B:<\/em><code>protected :greet<br \/>\n<\/code><\/p>\n<p><em>C:<\/em><\/p>\n<pre><code>def greet\n  super\nend\n<\/code><\/pre>\n<p><em>D:<\/em><\/p>\n<pre><code>alias_method :original_greet, :greet\n\ndef greet\n  original_greet\nend\n<\/code><\/pre>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label96340\" class=\"accordion_input\"><label for=\"label96340\">\u89e3\u7b54<\/label><\/p>\n<div class=\"accordion_content\"> \u6b63\u89e3\u306fB\u3067\u3059\u3002 <\/div>\n<\/div>\n<\/div>\n<h3 id=\"i-2\">\u5404\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u540c\u58eb\u306e\u95a2\u4fc2<\/h3>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30e9\u30b9\u3001\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u306e\u95a2\u4fc2\u306b\u3064\u3044\u3066\u306f\u51fa\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u51fa\u984c\u3055\u308c\u305f\u306e\u306f\u4ee5\u4e0b\u306e\u554f\u984c\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>\u4f55\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304b\uff1f<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30b3\u30fc\u30c9<\/span><\/p>\n<pre><code>module Foo\nend\nputs Foo.class #=&gt; ?\n<\/code><\/pre>\n<\/div>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label868\" class=\"accordion_input\"><label for=\"label868\">\u89e3\u7b54<\/label><\/p>\n<div class=\"accordion_content\"> \u6b63\u89e3\u306f\u300cModule\u300d\u3067\u3059 \u3002\u5f53\u305f\u308a\u524d\u3059\u304e\u3066\u9006\u306b\u8ff7\u3044\u307e\u3057\u305f\u3002<\/div>\n<\/div>\n<\/div>\n<p>\u3088\u304f\u51fa\u984c\u3055\u308c\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u554f\u984c\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>\u4f55\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304b\uff1f<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30b3\u30fc\u30c9<\/span><\/p>\n<pre><code>puts Class.superclass<\/code><\/pre>\n<\/div>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label17794\" class=\"accordion_input\"><label for=\"label17794\">\u89e3\u7b54<\/label><\/p>\n<div class=\"accordion_content\"> \u6b63\u89e3\u306f\u300cModule\u300d\u3067\u3059\u3002\u3064\u307e\u308aClass\u306f\u5168\u3066Module\u3067\u3082\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002 <\/div>\n<\/div>\n<\/div>\n<h3 id=\"i-3\">\u7d50\u5408\u5ea6\u306e\u554f\u984c<\/h3>\n<p>do \u2026 end\u3068{ }\u306e\u7d50\u5408\u5ea6\u306e\u9055\u3044\u306b\u3088\u308b\u6319\u52d5\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u306f\u51fa\u307e\u3057\u305f\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u554f\u984c\u3067\u3059\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>\u4ee5\u4e0b\u306e\u4e2d\u3067\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3082\u306e\u306f\u3069\u308c\u3067\u3059\u304b\uff1f<\/p>\n<p>A <code>3.upto(0) { |i| puts i }<\/code><\/p>\n<p>B <code>3.upto 0 { |i| puts i }<\/code><\/p>\n<p>C <code>3.upto(0) do |i| puts i end<\/code><\/p>\n<p>D <code>3.upto 0 do&nbsp;|i| puts i end<\/code><\/p>\n<p>&nbsp;<\/p>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label69961\" class=\"accordion_input\"><label for=\"label69961\">\u89e3\u7b54\u30fb\u89e3\u8aac<\/label><\/p>\n<div class=\"accordion_content\"> \u6b63\u89e3\u306f\u300cB\u300d\u3067\u3059\u3002{\u2026}\u306f\u7d50\u5408\u5ea6\u304c\u9ad8\u3044\u305f\u3081\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u8a18\u8ff0\u306f 3.upto (0 { |i| puts i })\u3068\u8a55\u4fa1\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306bp\u3092\u4f7f\u3046\u5834\u5408\u306f{\u2026}\u3092\u4f7f\u308f\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u3082\u62bc\u3055\u3048\u3066\u304a\u3044\u305f\u65b9\u304c\u3044\u3044\u3067\u3059\u3002<\/p><\/div>\n<\/div>\n<\/div>\n<h3 id=\"i-4\">DATA\u3068__END__\u3092\u9078\u3070\u305b\u308b\u554f\u984c<\/h3>\n<p>\u516c\u5f0f\u554f\u984c\u96c6\u306b\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u3001File\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u51fa\u3059\u969b\u306e\u6587\u6cd5\u306b\u3064\u3044\u3066\u51fa\u307e\u3057\u305f\u3002\u7b54\u3048\u306fDATA\u3068__END__\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u3059\u3002<\/p>\n<h3 id=\"i-5\">\u5927\u57df\u8131\u51fa<\/h3>\n<p>\u5927\u57df\u8131\u51fa\uff08\u305f\u3044\u3044\u304d\u3060\u3063\u3057\u3085\u3064\uff09\u306b\u3064\u3044\u3066\u3082\u51fa\u307e\u3057\u305f\u3002\u7b2c\u4e00\u5f15\u6570\u306b\u306f\u540c\u3058\u30bf\u30b0\u3092\u3001\u7b2c\u4e8c\u5f15\u6570\u306b\u306f\u8fd4\u308a\u5024\u3068\u3057\u3066\u53d6\u5f97\u3057\u305f\u3044\u3082\u306e\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>__(1)__\u306b\u5f53\u3066\u306f\u307e\u308b\u8a18\u8ff0\u306f\u3069\u308c\u3067\u3059\u304b\uff1f<\/p>\n<p>&nbsp;<\/p>\n<pre><code>letters = catch(:done) do\n  (\"a\"..\"z\").each do |a|\n    (\"a\"..\"z\").each do |b|\n      (\"a\"..\"z\").each do |c|\n        if a &lt; b &amp;&amp; b &lt; c\n          __(1)__\n        end\n      end\n    end\n  end\nend\n\nputs letters.join\n\n[\u51fa\u529b\u7d50\u679c]\nabc\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><em>A:<\/em>&nbsp;<code>throw [a,b,c]<\/code><\/p>\n<p><em>B:<\/em>&nbsp;<code>throw [a,b,c], :done<\/code><\/p>\n<p><em>C:<\/em>&nbsp;<code>throw :done, [a,b,c]<\/code><\/p>\n<p><em>D:<\/em>&nbsp;<code>raise :done, [a,b,c]<\/code><\/p>\n<p>&nbsp;<\/p>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label56111\" class=\"accordion_input\"><label for=\"label56111\">\u89e3\u7b54<\/label><\/p>\n<div class=\"accordion_content\"> \u7b54\u3048\u306f\u300cC\u300d\u3067\u3059 <\/div>\n<\/div>\n<\/div>\n<h3 id=\"i-6\">\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570 -I<\/h3>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570\u306e-I\u306b\u3064\u3044\u3066\u554f\u308f\u308c\u307e\u3057\u305f\u3002\u30ed\u30fc\u30c9\u30d1\u30b9\u3078\u8ffd\u52a0\u3055\u308c\u308b\u3068\u3044\u3063\u305f\u516c\u5f0f\u554f\u984c\u96c6\u3068\u540c\u3058\u554f\u984c\u304c\u51fa\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3 id=\"i-7\">\u53ef\u5909\u9577\u5f15\u6570\u306e\u6319\u52d5<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u53ef\u5909\u9577\u5f15\u6570\u306e\u6319\u52d5\u306f\u51fa\u307e\u3057\u305f\u3002<\/p>\n<div class=\"sng-box box2\">\n<p>\u4ee5\u4e0b\u306e\u51fa\u529b\u7d50\u679c\u306b\u306a\u308b\u30b3\u30fc\u30c9\u306f\u3069\u308c\u3067\u3059\u304b\uff1f<\/p>\n<pre><code>[[\"apple\", \"banana\", \"carrot\"]]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><em>A:<\/em><\/p>\n<pre><code>def fx(*args)\n  p(args)\nend\nfx(*[\"apple\", \"banana\", \"carrot\"])\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><em>B:<\/em><\/p>\n<pre><code>def fx(*args)\n  p(args)\nend\nfx([\"apple\", \"banana\", \"carrot\"])\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><em>C:<\/em><\/p>\n<pre><code>def fx(*args)\n  p(args)\nend\nfx(\"apple\", \"banana\", \"carrot\")\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><em>D:<\/em><\/p>\n<pre><code>def fx(*args)\n  p(*args)\nend\nfx([\"apple\", \"banana\", \"carrot\"])<\/code><\/pre>\n<p>&nbsp;<\/p>\n<div class=\"accordion main_c\"><input type=\"checkbox\" id=\"label17123\" class=\"accordion_input\"><label for=\"label17123\">\u89e3\u7b54<\/label><\/p>\n<div class=\"accordion_content\"> \u7b54\u3048\u306f\u300cB\u300d\u3067\u3059 <\/div>\n<\/div>\n<\/div>\n<p>\u3042\u3068\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5185\u5bb9\u3082\u51fa\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>&lt;=&gt;\u3092\u9078\u3070\u305b\u308b\u554f\u984c\u304c\u51fa\u305f<\/li>\n<li>\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570\u306b**\u3092\u6e21\u3057\u305f\u6642\u306e\u51fa\u529b\u304c\u3069\u3046\u306a\u308b\u304b\u306f\u51fa\u305f<\/li>\n<li>Date\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b+1\u3057\u305f\u6642\u306e\u6319\u52d5\u306f\u51fa\u305f<\/li>\n<li>puts x ** x\u3067\u7b54\u3048\u304c-1\u306b\u306a\u308b\u3088\u3046\u306b\u9078\u3070\u305b\u308b\u554f\u984c\u306f\u51fa\u305f 1i\u304c\u6b63\u89e3<\/li>\n<li>\u4eca\u56de\u306f\u51fa\u306a\u304b\u3063\u305f\u3051\u3069append feature\u306b\u95a2\u9023\u3059\u308b\u554f\u984c\u304c\u51fa\u308b\u3053\u3068\u3082\u3042\u308b\u3089\u3057\u3044<\/li>\n<li>\u4eca\u56de\u306finstance_eval\u3001module_eval\u306a\u3069\u306e\u6319\u52d5\u306f\u51fa\u306a\u304b\u3063\u305f<\/li>\n<li>prepend\u3001include\u3001extend\u3092\u9078\u3070\u305b\u308b\u554f\u984c\u306f\u51fa\u305f<\/li>\n<\/ul>\n<h4 id=\"i-8\">\u307e\u3068\u3081<\/h4>\n<p>\u4ee5\u4e0a\u306e\u3088\u3046\u306a\u5f62\u3067\u3059\u3002\u5c11\u3057\u3067\u3082\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\uff01\u3067\u306f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3046\u3082\u3001RubyGold\u306b\u5148\u65e5\u5408\u683c\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u3055\u3066\u4eca\u56de\u306f\u5b9f\u969b\u306b\u51fa\u984c\u3055\u308c\u305f\u554f\u984c\u3092\u3046\u308d\u899a\u3048\u3067\u3059\u304c\u3001\u7c21\u5358\u306b\u307e\u3068\u3081\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 Gold\u3067\u51fa\u984c\u3055\u308c\u305f\u554f\u984c\u3067\u60a9\u307e\u3057\u304b\u3063\u305f\u3082\u306e protected\u306e\u4f7f\u3044\u65b9 protecte &#8230; <\/p>\n","protected":false},"author":1,"featured_media":5747,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[272],"tags":[],"class_list":{"0":"post-5771","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-programing","8":"entry"},"_links":{"self":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/5771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5771"}],"version-history":[{"count":3,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/5771\/revisions"}],"predecessor-version":[{"id":5783,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/5771\/revisions\/5783"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/media\/5747"}],"wp:attachment":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}