{"id":5406,"date":"2015-07-12T03:12:36","date_gmt":"2015-07-11T18:12:36","guid":{"rendered":"http:\/\/www.vincentina.net\/?p=5406"},"modified":"2020-02-23T20:52:52","modified_gmt":"2020-02-23T11:52:52","slug":"%e4%ba%ba%e3%81%ae%e9%80%a0%e3%82%8a%e3%81%97%e3%82%82%e3%81%ae","status":"publish","type":"post","link":"https:\/\/www.vincentina.net\/?p=5406","title":{"rendered":"\u4eba\u306e\u9020\u308a\u3057\u3082\u306e"},"content":{"rendered":"<p>\u5927\u3057\u305f\u30cd\u30bf\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001Ruby\u306b\u306f\u4fbf\u5229\u306a\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308a\u3001\u305f\u304f\u3055\u3093\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4fbf\u5229\u3067\u826f\u3044\u306e\u3067\u3059\u304c\u3001Ruby\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u308b\u3068\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3069\u3093\u306a\u30b3\u30fc\u30c9\u3060\u308d\u3046\uff1f\u3068\u3044\u3046\u7591\u554f\u306b\u76f4\u9762\u3059\u308b\u3053\u3068\u304c\u7d50\u69cb\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3044\u307e\u3055\u3089\u611f\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u305d\u306e\u8fba\u3092\u3056\u3063\u304f\u308a\u63a2\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u984c\u6750\u3067Sort\u95a2\u6570\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\uff01\u3063\u3066\u306e\u306f\u6700\u521d\u306e\u9803\u306e\u30cd\u30bf\u3068\u3057\u3066\u826f\u304f\u53d6\u308a\u4e0a\u3052\u3089\u308c\u307e\u3059\u304c\u3001\u4eca\u56de\u3053\u306e\u304a\u984c\u76ee\u306b\u3057\u305f\u539f\u56e0\u306b\u306a\u3063\u305f\u306e\u306fDelete\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u306a\u306e\u3067\u3001Delete\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u3044\u304b\u3051\u3066\u884c\u304d\u307e\u305b\u3046<\/p>\n<p>\u30d9\u30fc\u30b7\u30c3\u30af\u306a3\u3064\u306e\u30af\u30e9\u30b9\u3002<\/p>\n<pre>\r\na = [1, 2]\r\na.class\r\n=> Array\r\n\r\nb = {1 => \"a\", 2 => \"b\"}\r\nb.class\r\n=> Hash\r\n\r\nc = \"hoge\"\r\nc.class\r\n=> String\r\n<\/pre>\n<p>\u305d\u3053\u306bDelete\u306f\u3042\u308b\u306e\u304b\u3044\uff1f<\/p>\n<pre>\r\na.methods.grep(\/delete$\/)\r\n=> [:delete]\r\nb.methods.grep(\/delete$\/)\r\n=> [:delete]\r\nc.methods.grep(\/delete$\/)\r\n=> [:delete]\r\n<\/pre>\n<p>\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u3067\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u898b\u308b\u305f\u3081\u306bRuby\u306e\u30bd\u30fc\u30b9\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<br \/>\n\u53e4\u3044\u3067\u3059\u3051\u3069\u30d9\u30fc\u30b7\u30c3\u30af\u306b\u4f7f\u3063\u3066\u3044\u308b2.0\u7cfb\u3067\u3057\u3002<\/p>\n<pre>\r\n$ ls -d \/tmp\/ruby-2.0.0-p645                                                                                      [\/tmp]\r\n\/tmp\/ruby-2.0.0-p645\r\n<\/pre>\n<p>\u30bd\u30fc\u30b9\u306a\u306e\u3067\u3001\u7686\u69d8\u3053\u3061\u3089\u306b\u3054\u63c3\u3044\u306b\u3054\u3056\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\n$ pwd\r\n\/tmp\/ruby-2.0.0-p645\r\n\r\n$ ls string.c\r\nstring.c\r\n\r\n$ ls hash.c\r\nhash.c\r\n\r\n$ ls array.c\r\narray.c\r\n<\/pre>\n<p>String\u30af\u30e9\u30b9\u3067\u78ba\u8a8d\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u7406\u7531\u306fString\u30af\u30e9\u30b9\u306eDelete\u3092\u4f7f\u3063\u3066\u305f\u304b\u3089\uff01<\/p>\n<p>5606\u884c\u76ee\u306b\u4f7f\u3044\u65b9\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3060\u3088\u3053\u308c\uff01<\/p>\n<pre>\r\n5606  *     \"hello\".delete \"l\",\"lo\"        #=> \"heo\"\r\n5607  *     \"hello\".delete \"lo\"            #=> \"he\"\r\n5608  *     \"hello\".delete \"aeiou\", \"^e\"   #=> \"hell\"\r\n5609  *     \"hello\".delete \"ej-m\"          #=> \"ho\"\r\n<\/pre>\n<p>\u30b3\u30fc\u30c9\u306f\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n<pre>\r\n5612 static VALUE\r\n5613 rb_str_delete(int argc, VALUE *argv, VALUE str)\r\n5614 {\r\n5615     str = rb_str_dup(str);\r\n5616     rb_str_delete_bang(argc, argv, str);\r\n5617     return str;\r\n5618 }\r\n<\/pre>\n<p>\u30b6\u30fc\u30c3\u3068\u30bd\u30fc\u30b9\u3092\u898b\u3066\u3044\u304f\u3068\u3001\u4f3c\u305f\u3088\u3046\u306a\u3084\u3064\u304c\u3053\u3093\u306a\u3068\u3053\u3082\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3042\u306eChomp\u3060\u3063\u305f\u308a<\/p>\n<pre>\r\n5612 static VALUE\r\n5613 rb_str_delete(int argc, VALUE *argv, VALUE str)\r\n5614 {\r\n5615     str = rb_str_dup(str);\r\n5616     rb_str_delete_bang(argc, argv, str);\r\n5617     return str;\r\n5618 }\r\n<\/pre>\n<p>Upcase\u3068\u304b\u3002<\/p>\n<pre>\r\n4848 static VALUE\r\n4849 rb_str_upcase(VALUE str)\r\n4850 {\r\n4851     str = rb_str_dup(str);\r\n4852     rb_str_upcase_bang(str);\r\n4853     return str;\r\n4854 }\r\n<\/pre>\n<p>\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u306d\u3002<br \/>\n1\u884c\u76ee\u306e&#8221;rb_str_dup&#8221;\u3092\u30b6\u30fc\u30c3\u3068\u898b\u308b\u3068Heap\u3068\u304bAlloc\u3068\u304b\u66f8\u3044\u3066\u308b\u306e\u3067\u9818\u57df\u306e\u78ba\u4fdd\u304b\u306a\u3041\u3002<br \/>\n2\u884c\u76ee\u304c\u4eca\u56de\u306e\u76ee\u7684\u306e\u90e8\u5206\u3067\u3059\uff01<br \/>\n\u3075\u3080\u3075\u3080\u3002<\/p>\n<p>\u30fb\u30fb\u30fb<\/p>\n<p>\u30b6\u30fc\u30c3\u3068\u898b\u307e\u3057\u305f\u304c\u3001\u305d\u3093\u306a\u306b\u30ea\u30fc\u30c7\u30a3\u30f3\u30b0\u30b9\u30ad\u30eb\u304c\u306a\u304b\u3063\u305f\u3053\u3068\u3092\u601d\u3044\u51fa\u3057\u305f\u306e\u3067\u3001\u3060\u3044\u305f\u3044\u8aad\u3093\u3060\u3068\u3053\u3067\u7d42\u308f\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\nstatic VALUE\r\nrb_str_delete_bang(int argc, VALUE *argv, VALUE str)\r\n{\r\n    char squeez[TR_TABLE_SIZE];\r\n    rb_encoding *enc = 0;\r\n    char *s, *send, *t;\r\n    VALUE del = 0, nodel = 0;\r\n\r\n\u301c\u301c\u301c\u3000\u7565 \u301c\u301c\u301c\r\n<\/pre>\n<p><span style=\"font-size: 16pt;\">\u77ed\u3063\uff01<\/span>\u3068\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u7d19\u9762\u306e\u90fd\u5408\u4e0a\u3053\u306e\u8fba\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3053\u3046\u3057\u3066C\u306e\u30bd\u30fc\u30b9\u3092\u773a\u3081\u3066\u305f\u3089\u3001\u3053\u308c\u304cRuby\u306a\u3093\u3060\u306a\u3041\u3068\u3001Ruby\u3082\u4eba\u304c\u4f5c\u3063\u305f\u3082\u306e\u306a\u3093\u3060\u306a\u3041\u3068\u6539\u3081\u3066\u5b9f\u611f\u3057\u305f\u3002<br \/>\n\u3063\u3066\u304bC\u8a00\u8a9e\u3082\u3084\u3093\uff01\u3063\u3066\u30c4\u30c3\u30b3\u30df\u306f\u4eca\u306f\u7f6e\u3044\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4eba\u304c\u305d\u308c\u3092\u305d\u3046\u3068\u8a8d\u8b58\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306a\u3093\u3066\u306e\u306f\u3001\u4eba\u305d\u308c\u305e\u308c\u306a\u3093\u3060\u304b\u3089\u306d\u3002<\/p>\n<p>\u6c17\u306b\u3057\u3066\u306a\u3044\u3051\u3069\u502b\u7406\u611f\u3068\u304b\u9053\u5fb3\u89b3\u306a\u3093\u304b\u3082\u3001\u8ab0\u304b\u304c\u4f5c\u3063\u305f\u8003\u3048\u65b9\u3092\u534a\u3070\u62bc\u3057\u4ed8\u3051\u3089\u308c\u3066\u3044\u308b\u611f\u3058\u3082\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\n\u57fa\u672c\u7684\u306b\u306f\u4eba\u69d8\u306b\u8ff7\u60d1\u3068\u30b3\u30fc\u30d2\u30fc\u306f\u304b\u3051\u3061\u3083\u3044\u3051\u306a\u3044\u3063\u3066\u4e8b\u3067\u3044\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3068\u3044\u3046\u304b\u3001\u4e16\u306e\u4e2d\u3001\u307b\u3068\u3093\u3069\u4eba\u304c\u5275\u3063\u305f\u3082\u306e\u3067\u3059\u306d\u3002<\/p>\n<p>\u4eba\u304c\u5275\u3063\u305f\u3082\u3093\u3058\u3083\u306a\u3044\u3063\u3066\u4f55\u3060\u308d\u3046\u306a\u3041\u3068\u8003\u3048\u305f\u3089\u30fb\u30fb<\/p>\n<p>\u305d\u308c\u306f<\/p>\n<p><span style=\"font-size: 16pt;\">\u611b\u3060<\/span><\/p>\n<p>\u3063\u3068\u3001\u8a71\u304c\u8131\u7dda\u3057\u307e\u304f\u308a\u3093\u3050\u3060\u3002\u305f\u3076\u3093\u30ea\u30e5\u30c3\u30af\u30fb\u30d9\u30c3\u30bd\u30f3\u306e\u6620\u753b\u3092\u898b\u305f\u304b\u3089\u3060\u308d\u3046\u3002<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30c6\u30fc\u30de\u3060\u3063\u305f\u306f\u305a\u306e\u3001\u300c\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3069\u3093\u306a\u30b3\u30fc\u30c9\u3060\u308d\u3046\uff1f\u300d\u3068\u3044\u3046\u8a71\u306f\u3069\u3053\u306b\u3044\u3063\u305f\u611f\u304c\u6e80\u8f09\u3067\u3059\u304c\u3001\u307e\u3041\u307e\u3041\u305d\u3093\u306a\u611f\u3058\u3067\u3002<br \/>\n\u304a\u6642\u9593\u3067\u3059\u3002\u3055\u3088\u3046\u306a\u3089\u3002<\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.vincentina.net\/?p=5406\" data-text=\"\u4eba\u306e\u9020\u308a\u3057\u3082\u306e\" data-via=\"TakekenTw\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u3057\u305f\u30cd\u30bf\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001Ruby\u306b\u306f\u4fbf\u5229\u306a\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308a\u3001\u305f\u304f\u3055\u3093\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002 \u4fbf\u5229\u3067\u826f\u3044\u306e\u3067\u3059\u304c\u3001Ruby\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u308b\u3068\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3069\u3093\u306a\u30b3\u30fc\u30c9\u3060\u308d\u3046\uff1f\u3068\u3044\u3046\u7591\u554f\u306b\u76f4\u9762\u3059\u308b\u3053\u3068\u304c\u7d50\u69cb\u3042\u308a &hellip; <a href=\"https:\/\/www.vincentina.net\/?p=5406\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u4eba\u306e\u9020\u308a\u3057\u3082\u306e&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106],"tags":[],"class_list":["post-5406","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.vincentina.net\/index.php?rest_route=\/wp\/v2\/posts\/5406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vincentina.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vincentina.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vincentina.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vincentina.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5406"}],"version-history":[{"count":0,"href":"https:\/\/www.vincentina.net\/index.php?rest_route=\/wp\/v2\/posts\/5406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vincentina.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vincentina.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vincentina.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}