{"id":130,"date":"2024-09-10T18:32:31","date_gmt":"2024-09-10T09:32:31","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=130"},"modified":"2025-03-24T08:55:02","modified_gmt":"2025-03-23T23:55:02","slug":"ruby%e5%88%9d%e5%bf%83%e8%80%85%e3%81%8b%e3%82%89%e3%82%a8%e3%82%ad%e3%82%b9%e3%83%91%e3%83%bc%e3%83%88%e3%81%be%e3%81%a7%ef%bc%9ainject%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%83%9e%e3%82%b9%e3%82%bf","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=130","title":{"rendered":"Ruby\u521d\u5fc3\u8005\u304b\u3089\u30a8\u30ad\u30b9\u30d1\u30fc\u30c8\u307e\u3067\uff1ainject\u30e1\u30bd\u30c3\u30c9\u30de\u30b9\u30bf\u30fc\u8b1b\u5ea7\u3010\u5b8c\u5168\u7248\u3011"},"content":{"rendered":"\n<p>Ruby\u306e<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u914d\u5217\u3084\u30cf\u30c3\u30b7\u30e5\u306a\u3069\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<br>\u521d\u5fc3\u8005\u306b\u3068\u3063\u3066\u306f\u5c11\u3057\u96e3\u89e3\u306b\u611f\u3058\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u306a\u308c\u3070\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u52b9\u7387\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u790e\u304b\u3089\u5fdc\u7528\u307e\u3067\u3001\u5b9f\u8df5\u7684\u306a\u4f8b\u3092\u4ea4\u3048\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u3053\u306e\u8a18\u4e8b\u3092\u901a\u3057\u3066\u7406\u89e3\u3067\u304d\u308b8\u3064\u306e\u3053\u3068<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ul class=\"wp-block-list\">\n<li>inject\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3068\u69cb\u6587<\/li>\n\n\n\n<li>inject\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u52d5\u4f5c\u306e\u4ed5\u7d44\u307f<\/li>\n\n\n\n<li>\u5b9f\u8df5\u7684\u306ainject\u30e1\u30bd\u30c3\u30c9\u306e\u6d3b\u7528\u4f8b\uff085\u3064\u306e\u5177\u4f53\u4f8b\uff09<\/li>\n\n\n\n<li>inject\u30e1\u30bd\u30c3\u30c9\u3068\u4ed6\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u306e\u9055\u3044\u3068\u4f7f\u3044\u5206\u3051<\/li>\n\n\n\n<li>inject\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/li>\n\n\n\n<li>\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067inject\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u969b\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/li>\n\n\n\n<li>\u4e0a\u7d1a\u8005\u5411\u3051\u306einject\u30e1\u30bd\u30c3\u30c9\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3068\u62e1\u5f35\u65b9\u6cd5<\/li>\n\n\n\n<li>inject\u30e1\u30bd\u30c3\u30c9\u306e\u30de\u30b9\u30bf\u30fc\u306b\u306a\u308b\u305f\u3081\u306e\u5b66\u7fd2\u30ed\u30fc\u30c9\u30de\u30c3\u30d7<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">1. inject\u30e1\u30bd\u30c3\u30c9\u3068\u306f\uff1f\u57fa\u790e\u304b\u3089\u5fdc\u7528\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">inject\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3068\u69cb\u6587<\/a>      <\/li>      <li>        <a href=\"#i-2\">inject\u30e1\u30bd\u30c3\u30c9\u306e\u52d5\u4f5c\u539f\u7406\uff1a\u5185\u90e8\u3067\u4f55\u304c\u8d77\u3053\u3063\u3066\u3044\u308b\u306e\u304b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-3\">\u521d\u671f\u5024\u306e\u91cd\u8981\u6027\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30ef\u30fc\u3092\u5f15\u304d\u51fa\u3059\u9375<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-4\">2. inject\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u8df5\u7684\u6d3b\u7528\u6cd5\uff1a5\u3064\u306e\u5177\u4f53\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-5\">\u914d\u5217\u306e\u8981\u7d20\u3092\u5408\u8a08\u3059\u308b\uff1a\u30b7\u30f3\u30d7\u30eb\u3060\u3051\u3069\u5f37\u529b\u306a\u4f7f\u3044\u65b9<\/a>      <\/li>      <li>        <a href=\"#i-6\">\u30cf\u30c3\u30b7\u30e5\u306e\u64cd\u4f5c\uff1a\u30ad\u30fc\u3068\u5024\u3092\u81ea\u5728\u306b\u5909\u63db<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u6587\u5b57\u5217\u306e\u9023\u7d50\uff1a\u52b9\u7387\u7684\u306a\u6587\u5b57\u5217\u51e6\u7406\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li>        <a href=\"#i-8\">\u30ab\u30b9\u30bf\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u96c6\u7d04\uff1a\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u6271\u3044\u65b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-9\">\u518d\u5e30\u7684\u306a\u51e6\u7406\uff1ainject\u30e1\u30bd\u30c3\u30c9\u3067\u6728\u69cb\u9020\u3092\u63a2\u7d22\u3059\u308b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-10\">3. inject\u30e1\u30bd\u30c3\u30c9vs\u4ed6\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\uff1a\u3069\u3046\u4f7f\u3044\u5206\u3051\u308b\uff1f<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-11\">each\u3001map\u3001reduce\u3068\u306e\u6bd4\u8f03\uff1a\u305d\u308c\u305e\u308c\u306e\u7279\u5fb4\u3068\u4f7f\u3044\u3069\u3053\u308d<\/a>      <\/li>      <li>        <a href=\"#i-12\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\uff1a\u3069\u306e\u5834\u9762\u3067inject\u304c\u6700\u9069\u304b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-13\">\u53ef\u8aad\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\uff1a\u30c1\u30fc\u30e0\u958b\u767a\u3067\u306e\u8003\u616e\u70b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-16\">4. inject\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u69cb\u9020\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-17\">Ruby\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u304b\u3089\u898b\u305finject\u30e1\u30bd\u30c3\u30c9\uff1a\u51e6\u7406\u306e\u6d41\u308c\u3092\u8ffd\u3046<\/a>      <\/li>      <li>        <a href=\"#i-18\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3068GC\uff08\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff09\u3078\u306e\u5f71\u97ff<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-19\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u306einject\u30e1\u30bd\u30c3\u30c9\uff1a\u6ce8\u610f\u70b9\u3068\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-24\">5. \u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067inject\u30e1\u30bd\u30c3\u30c9\u3092\u6d3b\u7528\u3059\u308b\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-25\">\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u6b66\u5668\u3068\u3057\u3066\u306einject\u30e1\u30bd\u30c3\u30c9\uff1a\u30b3\u30fc\u30c9\u3092\u30b7\u30f3\u30d7\u30eb\u306b<\/a>      <\/li>      <li>        <a href=\"#i-26\">\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3068inject\u30e1\u30bd\u30c3\u30c9\uff1a\u30c6\u30b9\u30c8\u3057\u3084\u3059\u3044\u30b3\u30fc\u30c9\u306e\u66f8\u304d\u65b9<\/a>      <\/li>      <li>        <a href=\"#i-27\">\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5165\u308a\u53e3\uff1ainject\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u5b66\u3076\u65b0\u3057\u3044\u30d1\u30e9\u30c0\u30a4\u30e0<\/a>      <\/li>      <li>        <a href=\"#i-28\">\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u9ad8\u3081\u308b\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-33\">\u30c1\u30fc\u30e0\u958b\u767a\u3067\u306e\u6ce8\u610f\u70b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-34\">\u4e00\u822c\u7684\u306a\u843d\u3068\u3057\u7a74\u3068\u56de\u907f\u7b56<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-35\">6. \u4e0a\u7d1a\u8005\u5411\u3051\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3068\u62e1\u5f35<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-36\">\u72ec\u81ea\u306eEnumerable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067inject\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-37\">\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3068inject\u30e1\u30bd\u30c3\u30c9\uff1a\u52d5\u7684\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u751f\u6210\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-38\">C\u8a00\u8a9e\u62e1\u5f35\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6975\u9650\u307e\u3067\u9ad8\u3081\u308b<\/a>      <\/li>      <li>        <a href=\"#i-39\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-40\">\u5c06\u6765\u306e\u5c55\u671b\u3068\u7d99\u7d9a\u7684\u5b66\u7fd2<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-41\">7. \u307e\u3068\u3081\uff1ainject\u30e1\u30bd\u30c3\u30c9\u30de\u30b9\u30bf\u30fc\u3078\u306e\u9053<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-42\">\u3055\u3089\u306a\u308b\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u7406\u89e3\u3092\u6df1\u3081\u308b\u305f\u3081\u306e\u63a8\u5968\u66f8\u7c4d\u3068\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-45\">\u3042\u306a\u305f\u306eRuby\u30b9\u30ad\u30eb\u3092\u6b21\u306e\u30ec\u30d9\u30eb\u306b\u5f15\u304d\u4e0a\u3052\u308b\uff1a\u5b9f\u8df5\u7684\u306a\u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-0\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">1. inject\u30e1\u30bd\u30c3\u30c9\u3068\u306f\uff1f\u57fa\u790e\u304b\u3089\u5fdc\u7528\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/span><\/span><\/h2>\n\n\n\n<p>Ruby\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3044\u3066\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8981\u7d20\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3063\u3066\u3044\u308b\u306a\u3089\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u307e\u3055\u306b\u5b9d\u306e\u5c71\u3067\u3059\u3002<br>\u3053\u306e\u5f37\u529b\u306a\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u914d\u5217\u3084\u30cf\u30c3\u30b7\u30e5\u306a\u3069\u306e\u8981\u7d20\u3092\u9806\u306b\u51e6\u7406\u3057\u3001\u6700\u7d42\u7684\u306a\u7d50\u679c\u3092\u751f\u6210\u3059\u308b\u969b\u306b\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">inject\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3068\u69cb\u6587<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u69cb\u6587\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">collection.inject(initial_value) { |accumulator, element| block }<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>collection<\/code>\u306f\u51e6\u7406\u5bfe\u8c61\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff08\u914d\u5217\u3084\u30cf\u30c3\u30b7\u30e5\u306a\u3069\uff09<\/li>\n\n\n\n<li><code>initial_value<\/code>\u306f\u96c6\u7d04\u306e\u521d\u671f\u5024\uff08\u7701\u7565\u53ef\u80fd\uff09<\/li>\n\n\n\n<li><code>accumulator<\/code>\u306f\u4e2d\u9593\u7d50\u679c\u3092\u4fdd\u6301\u3059\u308b\u5909\u6570<\/li>\n\n\n\n<li><code>element<\/code>\u306f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5404\u8981\u7d20<\/li>\n\n\n\n<li><code>block<\/code>\u306f\u5404\u8981\u7d20\u306b\u5bfe\u3057\u3066\u5b9f\u884c\u3055\u308c\u308b\u51e6\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u914d\u5217\u306e\u8981\u7d20\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sum = [1, 2, 3, 4, 5].inject(0) { |acc, n| acc + n }\nputs sum  # \u51fa\u529b: 15<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">inject\u30e1\u30bd\u30c3\u30c9\u306e\u52d5\u4f5c\u539f\u7406\uff1a\u5185\u90e8\u3067\u4f55\u304c\u8d77\u3053\u3063\u3066\u3044\u308b\u306e\u304b<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u52d5\u4f5c\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u306f\u3001\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u9375\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u521d\u671f\u5024\uff08\u6307\u5b9a\u3055\u308c\u305f\u5834\u5408\uff09\u307e\u305f\u306f\u6700\u521d\u306e\u8981\u7d20\u304c<code>accumulator<\/code>\u306b\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5404\u8981\u7d20\u306b\u5bfe\u3057\u3066\u30d6\u30ed\u30c3\u30af\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30d6\u30ed\u30c3\u30af\u306e\u623b\u308a\u5024\u304c\u6b21\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u306e<code>accumulator<\/code>\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u6700\u5f8c\u306e\u8981\u7d20\u307e\u3067\u51e6\u7406\u304c\u7d42\u308f\u308b\u3068\u3001\u6700\u7d42\u7684\u306a<code>accumulator<\/code>\u306e\u5024\u304c<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u623b\u308a\u5024\u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u521d\u671f\u5024\u306e\u91cd\u8981\u6027\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30ef\u30fc\u3092\u5f15\u304d\u51fa\u3059\u9375<\/h3>\n\n\n\n<p>\u521d\u671f\u5024\u306e\u6307\u5b9a\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u52d5\u4f5c\u306b\u5927\u304d\u306a\u5f71\u97ff\u3092\u4e0e\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521d\u671f\u5024\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u305d\u306e\u5024\u304b\u3089\u51e6\u7406\u304c\u958b\u59cb\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u521d\u671f\u5024\u3092\u7701\u7565\u3059\u308b\u3068\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u6700\u521d\u306e\u8981\u7d20\u304c\u521d\u671f\u5024\u3068\u3057\u3066\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u6587\u5b57\u5217\u306e\u9023\u7d50\u3092\u884c\u3046\u5834\u5408<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">## \u521d\u671f\u5024\u3042\u308a\nresult = ['Ruby', 'on', 'Rails'].inject('') { |acc, word| acc + word + ' ' }\nputs result.strip  # \u51fa\u529b: \"Ruby on Rails\"\n\n## \u521d\u671f\u5024\u306a\u3057\nresult = ['Ruby', 'on', 'Rails'].inject { |acc, word| acc + ' ' + word }\nputs result  # \u51fa\u529b: \"Ruby on Rails\"<\/pre>\n\n\n\n<p>\u521d\u671f\u5024\u306e\u9078\u629e\u306f\u3001\u7279\u306b\u7a7a\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u51e6\u7406\u3059\u308b\u5834\u5408\u3084\u3001\u7279\u5b9a\u306e\u578b\u306e\u7d50\u679c\u3092\u671f\u5f85\u3059\u308b\u5834\u5408\u306b\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5358\u7d14\u306a\u96c6\u8a08\u304b\u3089\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u5909\u63db\u307e\u3067\u3001\u5e45\u5e83\u3044\u30bf\u30b9\u30af\u306b\u9069\u7528\u3067\u304d\u308b\u67d4\u8edf\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<br>\u57fa\u672c\u3092\u62bc\u3055\u3048\u305f\u4e0a\u3067\u3001\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u3088\u308a\u5b9f\u8df5\u7684\u306a\u4f7f\u7528\u4f8b\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-4\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">2. inject\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u8df5\u7684\u6d3b\u7528\u6cd5\uff1a5\u3064\u306e\u5177\u4f53\u4f8b<\/span><\/span><\/h2>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u771f\u306e\u529b\u3092\u7406\u89e3\u3059\u308b\u306b\u306f\u3001\u5b9f\u8df5\u7684\u306a\u4f8b\u3092\u901a\u3058\u3066\u5b66\u3076\u306e\u304c\u6700\u3082\u52b9\u679c\u7684\u3067\u3059\u3002<br>\u3053\u3053\u3067\u306f\u3001\u65e5\u5e38\u7684\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30bf\u30b9\u30af\u306b\u304a\u3044\u3066<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u304c\u3069\u306e\u3088\u3046\u306b\u6d3b\u7528\u3067\u304d\u308b\u304b\u3092\u30015\u3064\u306e\u5177\u4f53\u4f8b\u3092\u901a\u3058\u3066\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u914d\u5217\u306e\u8981\u7d20\u3092\u5408\u8a08\u3059\u308b\uff1a\u30b7\u30f3\u30d7\u30eb\u3060\u3051\u3069\u5f37\u529b\u306a\u4f7f\u3044\u65b9<\/h3>\n\n\n\n<p>\u6700\u3082\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b\u3067\u3059\u304c\u3001\u305d\u306e\u7c21\u6f54\u3055\u3068\u52b9\u7387\u6027\u306f\u6ce8\u76ee\u306b\u5024\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">numbers = [1, 2, 3, 4, 5]\nsum = numbers.inject(0) { |acc, num| acc + num }\nputs sum  # \u51fa\u529b: 15\n\n## \u5225\u306e\u66f8\u304d\u65b9\nsum = numbers.inject(:+)\nputs sum  # \u51fa\u529b: 15<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u304c\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u9806\u306b\u51e6\u7406\u3057\u3001\u5408\u8a08\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<br>\u521d\u671f\u5024\u3068\u3057\u30660\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306f\u7a7a\u306e\u914d\u5217\u306b\u5bfe\u3057\u3066\u3082\u5b89\u5168\u306b\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u5076\u6570\u306e\u8981\u7d20\u306e\u307f\u3092\u5408\u8a08\u3059\u308b\u65b9\u6cd5\u3092<code>inject<\/code>\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u30cf\u30c3\u30b7\u30e5\u306e\u64cd\u4f5c\uff1a\u30ad\u30fc\u3068\u5024\u3092\u81ea\u5728\u306b\u5909\u63db<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u30cf\u30c3\u30b7\u30e5\u306e\u64cd\u4f5c\u306b\u3082\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u30cf\u30c3\u30b7\u30e5\u306e\u30ad\u30fc\u3068\u5024\u3092\u5165\u308c\u66ff\u3048\u308b\u64cd\u4f5c\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">original_hash = {\"a\" =&gt; 1, \"b\" =&gt; 2, \"c\" =&gt; 3}\ninverted_hash = original_hash.inject({}) do |acc, (key, value)|\n  acc = key\n  acc\nend\nputs inverted_hash  # \u51fa\u529b: {1=&gt;\"a\", 2=&gt;\"b\", 3=&gt;\"c\"}<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u65b0\u3057\u3044\u30cf\u30c3\u30b7\u30e5\u3092\u4f5c\u6210\u3057\u306a\u304c\u3089\u3001\u5143\u306e\u30cf\u30c3\u30b7\u30e5\u306e\u30ad\u30fc\u3068\u5024\u3092\u5165\u308c\u66ff\u3048\u3066\u3044\u307e\u3059\u3002<br><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u67d4\u8edf\u6027\u304c\u3001\u3053\u306e\u3088\u3046\u306a\u8907\u96d1\u306a\u5909\u63db\u3092\u7c21\u6f54\u306b\u8868\u73fe\u3059\u308b\u3053\u3068\u3092\u53ef\u80fd\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u30cf\u30c3\u30b7\u30e5\u306e\u5024\u3092\u3059\u3079\u30662\u500d\u306b\u3059\u308b\u64cd\u4f5c\u3092<code>inject<\/code>\u3067\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u6587\u5b57\u5217\u306e\u9023\u7d50\uff1a\u52b9\u7387\u7684\u306a\u6587\u5b57\u5217\u51e6\u7406\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>\u6587\u5b57\u5217\u306e\u9023\u7d50\u306f\u3001\u7279\u306b\u5927\u91cf\u306e\u6587\u5b57\u5217\u3092\u6271\u3046\u969b\u306b<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u52b9\u7387\u6027\u304c\u767a\u63ee\u3055\u308c\u308b\u5834\u9762\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">words = [\"Ruby\", \"is\", \"awesome\"]\nsentence = words.inject(\"\") { |acc, word| acc &lt;&lt; word &lt;&lt; \" \" }.strip\nputs sentence  # \u51fa\u529b: \"Ruby is awesome\"<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>&lt;&lt;<\/code>\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u6587\u5b57\u5217\u3092\u52b9\u7387\u7684\u306b\u9023\u7d50\u3057\u3066\u3044\u307e\u3059\u3002<br><code>+<\/code>\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3059\u308b\u3088\u308a\u3082\u30e1\u30e2\u30ea\u52b9\u7387\u304c\u826f\u304f\u3001\u5927\u91cf\u306e\u6587\u5b57\u5217\u3092\u6271\u3046\u969b\u306b\u7279\u306b\u6709\u52b9\u3067\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u914d\u5217\u5185\u306e\u6587\u5b57\u5217\u3092\u9006\u9806\u306b\u9023\u7d50\u3059\u308b\u65b9\u6cd5\u3092<code>inject<\/code>\u3067\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u30ab\u30b9\u30bf\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u96c6\u7d04\uff1a\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u6271\u3044\u65b9<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u8907\u96d1\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u96c6\u7d04\u306b\u3082\u4f7f\u3048\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u3001\u5546\u54c1\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u914d\u5217\u304b\u3089\u7dcf\u984d\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Product\n  attr_reader :name, :price\n  def initialize(name, price)\n    @name = name\n    @price = price\n  end\nend\n\nproducts = [\n  Product.new(\"Apple\", 100),\n  Product.new(\"Banana\", 80),\n  Product.new(\"Orange\", 120)\n]\n\ntotal_price = products.inject(0) { |acc, product| acc + product.price }\nputs total_price  # \u51fa\u529b: 300<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u304c\u5404<code>Product<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e<code>price<\/code>\u5c5e\u6027\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001\u7dcf\u984d\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u6700\u3082\u9ad8\u4fa1\u306a\u5546\u54c1\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u3092<code>inject<\/code>\u3067\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">\u518d\u5e30\u7684\u306a\u51e6\u7406\uff1ainject\u30e1\u30bd\u30c3\u30c9\u3067\u6728\u69cb\u9020\u3092\u63a2\u7d22\u3059\u308b<\/h3>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u3088\u308a\u9ad8\u5ea6\u306a\u4f8b\u3068\u3057\u3066\u3001\u30c4\u30ea\u30fc\u69cb\u9020\u306e\u63a2\u7d22\u306b<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class TreeNode\n  attr_reader :value, :children\n  def initialize(value, children = [])\n    @value = value\n    @children = children\n  end\n\n  def sum_values\n    [@value] + @children.inject([]) { |acc, child| acc + child.sum_values }\n  end\nend\n\nroot = TreeNode.new(1, [\n  TreeNode.new(2, [TreeNode.new(4), TreeNode.new(5)]),\n  TreeNode.new(3, [TreeNode.new(6)])\n])\n\nputs root.sum_values.inject(:+)  # \u51fa\u529b: 21<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u518d\u5e30\u7684\u306b\u4f7f\u7528\u3057\u3066\u30c4\u30ea\u30fc\u69cb\u9020\u5168\u4f53\u306e\u5024\u3092\u5408\u8a08\u3057\u3066\u3044\u307e\u3059\u3002<br>\u5404\u30ce\u30fc\u30c9\u304c\u81ea\u8eab\u306e\u5024\u3068\u5b50\u30ce\u30fc\u30c9\u306e\u5024\u3092\u96c6\u7d04\u3059\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u69cb\u9020\u3082\u52b9\u7387\u7684\u306b\u51e6\u7406\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u30c4\u30ea\u30fc\u69cb\u9020\u306e\u6df1\u3055\u3092\u8a08\u7b97\u3059\u308b\u65b9\u6cd5\u3092<code>inject<\/code>\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u4f8b\u3092\u901a\u3058\u3066\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u591a\u69d8\u6027\u3068\u5f37\u529b\u3055\u304c\u304a\u5206\u304b\u308a\u3044\u305f\u3060\u3051\u305f\u3067\u3057\u3087\u3046\u304b\u3002<br>\u30b7\u30f3\u30d7\u30eb\u306a\u96c6\u8a08\u304b\u3089\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u64cd\u4f5c\u307e\u3067\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u5e45\u5e83\u3044\u30b7\u30ca\u30ea\u30aa\u3067\u6d3b\u7528\u3067\u304d\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3068\u4ed6\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u3092\u6bd4\u8f03\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u7279\u5fb4\u3068\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-10\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">3. inject\u30e1\u30bd\u30c3\u30c9vs\u4ed6\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\uff1a\u3069\u3046\u4f7f\u3044\u5206\u3051\u308b\uff1f<\/span><\/span><\/h2>\n\n\n\n<p>Ruby\u306b\u306f\u69d8\u3005\u306a\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u9069\u5207\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u30b3\u30fc\u30c9\u306e\u52b9\u7387\u6027\u3001\u53ef\u8aad\u6027\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u304c\u5927\u304d\u304f\u5411\u4e0a\u3057\u307e\u3059\u3002<br>\u3053\u3053\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3068\u4ed6\u306e\u4e3b\u8981\u306a\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u3092\u6bd4\u8f03\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u7279\u5fb4\u3068\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">each\u3001map\u3001reduce\u3068\u306e\u6bd4\u8f03\uff1a\u305d\u308c\u305e\u308c\u306e\u7279\u5fb4\u3068\u4f7f\u3044\u3069\u3053\u308d<\/h3>\n\n\n\n<p>\u307e\u305a\u3001\u4e3b\u8981\u306a\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u7279\u5fb4\u3092\u6bd4\u8f03\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>each<\/strong>: \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5404\u8981\u7d20\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u304c\u3001\u65b0\u3057\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306f\u4f5c\u6210\u3057\u307e\u305b\u3093\u3002<\/li>\n\n\n\n<li><strong>map<\/strong>: \u5404\u8981\u7d20\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u884c\u3044\u3001\u305d\u306e\u7d50\u679c\u304b\u3089\u65b0\u3057\u3044\u914d\u5217\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>reduce<\/strong>: <code>inject<\/code>\u306e\u30a8\u30a4\u30ea\u30a2\u30b9\u3067\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8981\u7d20\u3092\u96c6\u7d04\u3057\u3066\u5358\u4e00\u306e\u7d50\u679c\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>inject<\/strong>: <code>reduce<\/code>\u3068\u540c\u3058\u304f\u3001\u8981\u7d20\u3092\u96c6\u7d04\u3057\u307e\u3059\u304c\u3001\u3088\u308a\u67d4\u8edf\u306a\u521d\u671f\u5024\u306e\u6307\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u305d\u308c\u305e\u308c\u306e\u4f7f\u7528\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">numbers = [1, 2, 3, 4, 5]\n\n## each\nsum = 0\nnumbers.each { |n| sum += n }\nputs sum  # \u51fa\u529b: 15\n\n## map\nsquared = numbers.map { |n| n ** 2 }\nputs squared.inspect  # \u51fa\u529b: [1, 4, 9, 16, 25]\n\n## reduce\/inject\nsum = numbers.reduce(0) { |acc, n| acc + n }\nputs sum  # \u51fa\u529b: 15\n\n## inject with symbol\nproduct = numbers.inject(:*)\nputs product  # \u51fa\u529b: 120<\/pre>\n\n\n\n<p><code>inject<\/code>\uff08\u307e\u305f\u306f<code>reduce<\/code>\uff09\u306f\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5168\u4f53\u3092\u5358\u4e00\u306e\u5024\u306b\u96c6\u7d04\u3059\u308b\u5834\u5408\u306b\u7279\u306b\u6709\u7528\u3067\u3059\u3002<br>\u4e00\u65b9\u3001<code>each<\/code>\u306f\u526f\u4f5c\u7528\u3092\u4f34\u3046\u51e6\u7406\u306b\u3001<code>map<\/code>\u306f\u5404\u8981\u7d20\u3092\u5909\u63db\u3057\u3066\u65b0\u3057\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u5834\u5408\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\uff1a\u3069\u306e\u5834\u9762\u3067inject\u304c\u6700\u9069\u304b<\/h3>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u89b3\u70b9\u304b\u3089\u898b\u308b\u3068\u3001\u4e00\u822c\u7684\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u50be\u5411\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5358\u7d14\u306a\u96c6\u8a08\u64cd\u4f5c\uff08\u5408\u8a08\u3001\u7a4d\u306a\u3069\uff09\u3067\u306f\u3001<code>inject<\/code>\u3068<code>each<\/code>\u306f\u307b\u307c\u540c\u7b49\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u793a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u5bfe\u3057\u3066\u306f\u3001<code>inject<\/code>\u304c\u308f\u305a\u304b\u306b\u512a\u4f4d\u306a\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u65b0\u3057\u3044\u914d\u5217\u3092\u751f\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001<code>map<\/code>\u306e\u65b9\u304c<code>inject<\/code>\u3088\u308a\u3082\u52b9\u7387\u7684\u3067\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u5927\u304d\u306a\u914d\u5217\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">require 'benchmark'\n\nbig_array = (1..1_000_000).to_a\n\nBenchmark.bm do |x|\n  x.report(\"inject:\") { big_array.inject(:+) }\n  x.report(\"each:\") { sum = 0; big_array.each { |n| sum += n }; sum }\n  x.report(\"sum:\") { big_array.sum }  # Ruby 2.4\u4ee5\u964d\u3067\u5229\u7528\u53ef\u80fd\nend<\/pre>\n\n\n\n<p>\u3053\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3067\u306f\u3001<code>inject<\/code>\u3068<code>each<\/code>\u306f\u307b\u307c\u540c\u7b49\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u793a\u3057\u307e\u3059\u304c\u3001\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u306f<code>inject<\/code>\u304c\u308f\u305a\u304b\u306b\u9ad8\u901f\u306a\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<br>\u305f\u3060\u3057\u3001Ruby 2.4\u4ee5\u964d\u3067\u5c0e\u5165\u3055\u308c\u305f<code>sum<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6570\u5024\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u306b\u6700\u3082\u9ad8\u901f\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u53ef\u8aad\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\uff1a\u30c1\u30fc\u30e0\u958b\u767a\u3067\u306e\u8003\u616e\u70b9<\/h3>\n\n\n\n<p>\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306f\u3001\u7279\u306b\u30c1\u30fc\u30e0\u958b\u767a\u306b\u304a\u3044\u3066\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-14\">1. <strong>\u53ef\u8aad\u6027<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>each<\/code>\u306f\u6700\u3082\u76f4\u611f\u7684\u3067\u3001\u526f\u4f5c\u7528\u3092\u4f34\u3046\u51e6\u7406\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>map<\/code>\u306f\u5909\u63db\u64cd\u4f5c\u3092\u660e\u78ba\u306b\u8868\u73fe\u3067\u304d\u3001\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u30d1\u30e9\u30c0\u30a4\u30e0\u3068\u76f8\u6027\u304c\u826f\u3044\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>inject<\/code>\u306f\u8907\u96d1\u306a\u96c6\u7d04\u51e6\u7406\u3092\u7c21\u6f54\u306b\u8868\u73fe\u3067\u304d\u307e\u3059\u304c\u3001\u4f7f\u3044\u65b9\u306b\u3088\u3063\u3066\u306f\u53ef\u8aad\u6027\u304c\u4f4e\u4e0b\u3059\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-15\">2. <strong>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>each<\/code>\u3068<code>map<\/code>\u306f\u76ee\u7684\u304c\u660e\u78ba\u3067\u3001\u5f8c\u304b\u3089\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u3059\u308b\u969b\u306b\u610f\u56f3\u3092\u7406\u89e3\u3057\u3084\u3059\u3044\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>inject<\/code>\u306f\u67d4\u8edf\u6027\u304c\u9ad8\u3044\u5206\u3001\u8907\u96d1\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u308b<\/li>\n\n\n\n<li><code>inject<\/code>\u306f\u67d4\u8edf\u6027\u304c\u9ad8\u3044\u5206\u3001\u8907\u96d1\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u610f\u56f3\u3092\u7406\u89e3\u3059\u308b\u306e\u306b\u6642\u9593\u304c\u304b\u304b\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u9069\u5207\u306a\u30b3\u30e1\u30f3\u30c8\u3084\u660e\u78ba\u306a\u5909\u6570\u540d\u304c\u91cd\u8981\u3067\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u30c1\u30fc\u30e0\u958b\u767a\u3067\u306e\u9078\u629e\u57fa\u6e96<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bf\u30b9\u30af\u306e\u6027\u8cea<\/strong>: \u5358\u7d14\u306a\u7e70\u308a\u8fd4\u3057\u306a\u3089<code>each<\/code>\u3001\u8981\u7d20\u306e\u5909\u63db\u306a\u3089<code>map<\/code>\u3001\u96c6\u7d04\u51e6\u7406\u306a\u3089<code>inject<\/code>\u3092\u9078\u629e\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30fc\u30c9\u306e\u660e\u78ba\u3055<\/strong>: \u51e6\u7406\u306e\u610f\u56f3\u304c\u660e\u78ba\u306b\u4f1d\u308f\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u9078\u3076\u3002<\/li>\n\n\n\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8981\u4ef6<\/strong>: \u5927\u898f\u6a21\u30c7\u30fc\u30bf\u3084\u983b\u7e41\u306b\u5b9f\u884c\u3055\u308c\u308b\u90e8\u5206\u3067\u306f\u3001\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3092\u53d6\u3063\u3066\u6700\u9069\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u9078\u629e\u3002<\/li>\n\n\n\n<li><strong>\u30c1\u30fc\u30e0\u306e\u7fd2\u719f\u5ea6<\/strong>: \u30c1\u30fc\u30e0\u30e1\u30f3\u30d0\u30fc\u306e Ruby \u3068\u5404\u30e1\u30bd\u30c3\u30c9\u3078\u306e\u7fd2\u719f\u5ea6\u3092\u8003\u616e\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001\u540c\u3058\u30bf\u30b9\u30af\u3092\u7570\u306a\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u5b9f\u88c5\u3057\u305f\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">products = [\n  {name: \"Apple\", price: 100},\n  {name: \"Banana\", price: 80},\n  {name: \"Orange\", price: 120}\n]\n\n## inject \u3092\u4f7f\u7528\ntotal_price_inject = products.inject(0) { |sum, product| sum + product[:price] }\n\n## each \u3092\u4f7f\u7528\ntotal_price_each = 0\nproducts.each { |product| total_price_each += product[:price] }\n\n## map \u3068 sum \u3092\u4f7f\u7528 (Ruby 2.4\u4ee5\u964d)\ntotal_price_map_sum = products.map { |product| product[:price] }.sum\n\nputs \"Total price (inject): #{total_price_inject}\"\nputs \"Total price (each): #{total_price_each}\"\nputs \"Total price (map + sum): #{total_price_map_sum}\"<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>inject<\/code>\u304c\u6700\u3082\u7c21\u6f54\u3067\u3059\u304c\u3001<code>each<\/code>\u306e\u65b9\u304c\u521d\u5fc3\u8005\u306b\u306f\u7406\u89e3\u3057\u3084\u3059\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<br><code>map<\/code>\u3068<code>sum<\/code>\u306e\u7d44\u307f\u5408\u308f\u305b\u306f\u3001\u9014\u4e2d\u306e\u5909\u63db\u904e\u7a0b\u304c\u660e\u78ba\u306b\u5206\u304b\u308c\u308b\u305f\u3081\u3001\u8907\u96d1\u306a\u51e6\u7406\u3092\u884c\u3046\u969b\u306b\u6709\u7528\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u7d50\u8ad6\u3068\u3057\u3066\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u5f37\u529b\u3067\u67d4\u8edf\u6027\u304c\u9ad8\u3044\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001\u5e38\u306b\u6700\u9069\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br>\u30bf\u30b9\u30af\u306e\u6027\u8cea\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3001\u30c1\u30fc\u30e0\u306e\u7fd2\u719f\u5ea6\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8981\u4ef6\u306a\u3069\u3092\u7dcf\u5408\u7684\u306b\u5224\u65ad\u3057\u3001\u9069\u5207\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p><strong>\u6f14\u7fd2<\/strong>: \u4ee5\u4e0b\u306e\u30bf\u30b9\u30af\u306b\u5bfe\u3057\u3066\u3001<code>inject<\/code>\u3001<code>each<\/code>\u3001<code>map<\/code>\u306e\u3069\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u6700\u9069\u304b\u3092\u8003\u3048\u3001\u305d\u306e\u7406\u7531\u3092\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6587\u5b57\u5217\u306e\u914d\u5217\u304b\u3089\u6700\u3082\u9577\u3044\u6587\u5b57\u5217\u3092\u898b\u3064\u3051\u308b\u3002<\/li>\n\n\n\n<li>\u6570\u5024\u306e\u914d\u5217\u306e\u5404\u8981\u7d20\u30922\u500d\u306b\u3059\u308b\u3002<\/li>\n\n\n\n<li>\u30cf\u30c3\u30b7\u30e5\u306e\u5024\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308b\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6f14\u7fd2\u3092\u901a\u3058\u3066\u3001\u5404\u30e1\u30bd\u30c3\u30c9\u306e\u7279\u5fb4\u3068\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u306e\u7406\u89e3\u3092\u6df1\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u69cb\u9020\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-16\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">4. inject\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u69cb\u9020\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/span><\/span><\/h2>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u975e\u5e38\u306b\u5f37\u529b\u3067\u67d4\u8edf\u6027\u304c\u9ad8\u3044\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001\u305d\u306e\u5185\u90e8\u69cb\u9020\u3092\u7406\u89e3\u3057\u3001\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3055\u3089\u306a\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u5411\u4e0a\u304c\u671f\u5f85\u3067\u304d\u307e\u3059\u3002<br>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u52d5\u4f5c\u3092\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u3001\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u306e\u4f7f\u7528\u6642\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">Ruby\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u304b\u3089\u898b\u305finject\u30e1\u30bd\u30c3\u30c9\uff1a\u51e6\u7406\u306e\u6d41\u308c\u3092\u8ffd\u3046<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u5b9f\u88c5\u3092\u7c21\u7565\u5316\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Array\n  def inject(initial = nil)\n    if initial.nil?\n      accumulator = self.first\n      start_index = 1\n    else\n      accumulator = initial\n      start_index = 0\n    end\n\n    self[start_index..-1].each do |element|\n      accumulator = yield(accumulator, element)\n    end\n\n    accumulator\n  end\nend<\/pre>\n\n\n\n<p>Ruby\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u306f\u3001\u3053\u306e\u51e6\u7406\u3092\u4ee5\u4e0b\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u521d\u671f\u5024\u306e\u6709\u7121\u3092\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30a2\u30ad\u30e5\u30e0\u30ec\u30fc\u30bf\u306e\u521d\u671f\u5316<\/li>\n\n\n\n<li>\u914d\u5217\u306e\u5404\u8981\u7d20\u306b\u5bfe\u3057\u3066\u30d6\u30ed\u30c3\u30af\u3092\u5b9f\u884c<\/li>\n\n\n\n<li>\u30d6\u30ed\u30c3\u30af\u306e\u7d50\u679c\u3092\u30a2\u30ad\u30e5\u30e0\u30ec\u30fc\u30bf\u306b\u683c\u7d0d<\/li>\n\n\n\n<li>\u6700\u7d42\u7684\u306a\u30a2\u30ad\u30e5\u30e0\u30ec\u30fc\u30bf\u306e\u5024\u3092\u8fd4\u3059<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u306e\u904e\u7a0b\u3067\u3001Ruby\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u306f\u6700\u9069\u5316\u3092\u884c\u3044\u3001\u53ef\u80fd\u306a\u9650\u308a\u52b9\u7387\u7684\u306b\u51e6\u7406\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u3001JIT\u30b3\u30f3\u30d1\u30a4\u30e9\uff08Ruby 2.6\u4ee5\u964d\uff09\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u983b\u7e41\u306b\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306f\u30cd\u30a4\u30c6\u30a3\u30d6\u30b3\u30fc\u30c9\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u3001\u5b9f\u884c\u901f\u5ea6\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3068GC\uff08\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff09\u3078\u306e\u5f71\u97ff<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306f\u3001\u4e3b\u306b\u4ee5\u4e0b\u306e\u8981\u56e0\u306b\u5f71\u97ff\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u51e6\u7406\u5bfe\u8c61\u306e\u914d\u5217\u306e\u30b5\u30a4\u30ba<\/li>\n\n\n\n<li>\u30d6\u30ed\u30c3\u30af\u5185\u3067\u306e\u4e2d\u9593\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u751f\u6210<\/li>\n\n\n\n<li>\u30a2\u30ad\u30e5\u30e0\u30ec\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u578b\u3068\u5927\u304d\u3055<\/li>\n<\/ol>\n\n\n\n<p>\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u51e6\u7406\u3059\u308b\u969b\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5897\u5927\u3057\u3001\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff08GC\uff09\u306e\u983b\u5ea6\u304c\u4e0a\u304c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u308c\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">GC\u306e\u5f71\u97ff\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u305f\u3081\u306e\u30d2\u30f3\u30c83\u9078<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u8981\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210\u3092\u907f\u3051\u308b<\/li>\n\n\n\n<li>\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u7528\u3059\u308b<\/li>\n\n\n\n<li>\u5927\u304d\u306a\u914d\u5217\u3092\u51e6\u7406\u3059\u308b\u969b\u306f\u3001\u30d0\u30c3\u30c1\u51e6\u7406\u3092\u691c\u8a0e\u3059\u308b<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u306einject\u30e1\u30bd\u30c3\u30c9\uff1a\u6ce8\u610f\u70b9\u3068\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u51e6\u7406\u3059\u308b\u969b\u306e<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u6ce8\u610f\u70b9\u3068\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-20\">1. <strong>\u30e1\u30e2\u30ea\u52b9\u7387<\/strong><\/h4>\n\n\n\n<p>\u5927\u304d\u306a\u914d\u5217\u3092\u4e00\u5ea6\u306b\u51e6\u7406\u3059\u308b\u3068\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u6025\u6fc0\u306b\u5897\u52a0\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u306e\u5834\u5408\u3001\u914d\u5217\u3092\u5c0f\u3055\u306a\u30c1\u30e3\u30f3\u30af\u306b\u5206\u5272\u3057\u3066\u51e6\u7406\u3059\u308b\u3053\u3068\u3067\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6291\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   def process_large_array(array, chunk_size = 1000)\n     array.each_slice(chunk_size).inject(0) do |sum, chunk|\n       sum + chunk.inject(0, :+)\n     end\n   end\n\n   large_array = (1..1_000_000).to_a\n   result = process_large_array(large_array)\n   puts result<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-21\">2. <strong>\u4e26\u5217\u51e6\u7406<\/strong><\/h4>\n\n\n\n<p>Ruby 2.3\u4ee5\u964d\u3067\u306f\u3001<code>parallel<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u4e26\u5217\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u3053\u308c\u306b\u3088\u308a\u3001\u30de\u30eb\u30c1\u30b3\u30a2\u30d7\u30ed\u30bb\u30c3\u30b5\u3092\u52b9\u7387\u7684\u306b\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   require 'parallel'\n\n   large_array = (1..1_000_000).to_a\n   result = Parallel.map(large_array.each_slice(1000).to_a) do |chunk|\n     chunk.inject(0, :+)\n   end.inject(0, :+)\n\n   puts result<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-22\">3. <strong>\u9069\u5207\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u9078\u629e<\/strong><\/h4>\n\n\n\n<p>\u51e6\u7406\u306e\u5185\u5bb9\u306b\u3088\u3063\u3066\u306f\u3001\u914d\u5217\u306e\u4ee3\u308f\u308a\u306b\u30cf\u30c3\u30b7\u30e5\u3084\u5c02\u7528\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u5411\u4e0a\u3059\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-23\">4. <strong>\u30d6\u30ed\u30c3\u30af\u306e\u6700\u9069\u5316<\/strong><\/h4>\n\n\n\n<p>\u30d6\u30ed\u30c3\u30af\u5185\u306e\u51e6\u7406\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u4fdd\u3061\u3001\u4e0d\u8981\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210\u3092\u907f\u3051\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u7528\u3059\u308b\u524d\u5f8c\u3067\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">require 'benchmark'\n\nlarge_array = (1..1_000_000).to_a\n\nBenchmark.bm do |x|\n  x.report(\"Normal inject:\") do\n    large_array.inject(0) { |sum, n| sum + n }\n  end\n\n  x.report(\"Optimized inject:\") do\n    process_large_array(large_array)\n  end\n\n  x.report(\"Parallel inject:\") do\n    Parallel.map(large_array.each_slice(1000).to_a) do |chunk|\n      chunk.inject(0, :+)\n    end.inject(0, :+)\n  end\nend<\/pre>\n\n\n\n<p>\u3053\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u5404\u30a2\u30d7\u30ed\u30fc\u30c1\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u9055\u3044\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3092\u884c\u3046\u969b\u306e\u30d2\u30f3\u30c8\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6700\u9069\u5316\u306e\u524d\u306b\u5fc5\u305a\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u3092\u884c\u3044\u3001\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u3092\u7279\u5b9a\u3059\u308b<\/li>\n\n\n\n<li>\u5c0f\u3055\u306a\u6539\u5584\u3092\u7a4d\u307f\u91cd\u306d\u308b\u3002\u5927\u304d\u306a\u5909\u66f4\u306f\u4e88\u671f\u305b\u306c\u5f71\u97ff\u3092\u53ca\u307c\u3059\u53ef\u80fd\u6027\u304c\u3042\u308b<\/li>\n\n\n\n<li>\u6700\u9069\u5316\u5f8c\u3082\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u30c6\u30b9\u30c8\u3092\u5145\u5b9f\u3055\u305b\u308b<\/li>\n\n\n\n<li>\u53ef\u8aad\u6027\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u30d0\u30e9\u30f3\u30b9\u3092\u53d6\u308b\u3002\u6975\u7aef\u306a\u6700\u9069\u5316\u306f\u4fdd\u5b88\u6027\u3092\u4f4e\u4e0b\u3055\u305b\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b<\/li>\n<\/ol>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u69cb\u9020\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306b\u3064\u3044\u3066\u7406\u89e3\u3092\u6df1\u3081\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u5805\u7262\u306aRuby\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u6d3b\u7528\u3059\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-24\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">5. \u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067inject\u30e1\u30bd\u30c3\u30c9\u3092\u6d3b\u7528\u3059\u308b\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/span><\/span><\/h2>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001\u9069\u5207\u306b\u4f7f\u7528\u3057\u306a\u3044\u3068\u53ef\u8aad\u6027\u306e\u4f4e\u4e0b\u3084\u30d0\u30b0\u306e\u539f\u56e0\u3068\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u6b66\u5668\u3068\u3057\u3066\u306einject\u30e1\u30bd\u30c3\u30c9\uff1a\u30b3\u30fc\u30c9\u3092\u30b7\u30f3\u30d7\u30eb\u306b<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u8907\u96d1\u306a\u51e6\u7406\u3092\u7c21\u6f54\u306b\u8868\u73fe\u3067\u304d\u308b\u305f\u3081\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u5f37\u529b\u306a\u6b66\u5668\u3068\u306a\u308a\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u914d\u5217\u306e\u8981\u7d20\u3092\u6761\u4ef6\u306b\u5fdc\u3058\u3066\u5206\u985e\u3059\u308b\u51e6\u7406\u306e\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">## \u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u524d\ndef classify_numbers(numbers)\n  even = []\n  odd = []\n  numbers.each do |n|\n    if n.even?\n      even &lt;&lt; n\n    else\n      odd &lt;&lt; n\n    end\n  end\n  { even: even, odd: odd }\nend\n\n## \u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u5f8c\ndef classify_numbers(numbers)\n  numbers.inject({ even: [], odd: [] }) do |result, n|\n    key = n.even? ? :even : :odd\n    result[key] &lt;&lt; n\n    result\n  end\nend\n\nnumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nputs classify_numbers(numbers)<\/pre>\n\n\n\n<p>\u3053\u306e\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306b\u3088\u308a\u3001\u30b3\u30fc\u30c9\u306e\u884c\u6570\u304c\u6e1b\u5c11\u3057\u3001\u51e6\u7406\u306e\u610f\u56f3\u304c\u3088\u308a\u660e\u78ba\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3068inject\u30e1\u30bd\u30c3\u30c9\uff1a\u30c6\u30b9\u30c8\u3057\u3084\u3059\u3044\u30b3\u30fc\u30c9\u306e\u66f8\u304d\u65b9<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u969b\u3001\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u306f\u7279\u306b\u6709\u52b9\u3067\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001TDD\u3092\u7528\u3044\u3066<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">require 'minitest\/autorun'\n\nclass ArrayExtensionsTest &lt; Minitest::Test\n  def test_sum_of_squares\n    assert_equal 385, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].sum_of_squares\n  end\nend\n\nclass Array\n  def sum_of_squares\n    inject(0) { |sum, n| sum + n ** 2 }\n  end\nend<\/pre>\n\n\n\n<p>\u3053\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3067\u306f\u3001\u307e\u305a\u30c6\u30b9\u30c8\u3092\u66f8\u304d\u3001\u305d\u306e\u30c6\u30b9\u30c8\u3092\u6e80\u305f\u3059\u3088\u3046\u306b<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u88c5\u3092\u884c\u3044\u307e\u3059\u3002<br>\u3053\u308c\u306b\u3088\u308a\u3001\u6a5f\u80fd\u306e\u6b63\u78ba\u6027\u3092\u78ba\u4fdd\u3057\u3064\u3064\u3001\u30b7\u30f3\u30d7\u30eb\u3067\u660e\u78ba\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5165\u308a\u53e3\uff1ainject\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u5b66\u3076\u65b0\u3057\u3044\u30d1\u30e9\u30c0\u30a4\u30e0<\/h3>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6982\u5ff5\u3092 Ruby \u306b\u53d6\u308a\u5165\u308c\u308b\u826f\u3044\u5165\u308a\u53e3\u3068\u306a\u308a\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u7279\u5fb4\u3067\u3042\u308b\u300c\u4e0d\u5909\u6027\u300d\u3068\u300c\u526f\u4f5c\u7528\u306e\u6700\u5c0f\u5316\u300d\u3092\u610f\u8b58\u3057\u305f<code>inject<\/code>\u306e\u4f7f\u7528\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def word_frequencies(text)\n  text.downcase.split.inject(Hash.new(0)) do |freq, word|\n    freq.merge(word =&gt; freq[word] + 1)\n  end\nend\n\ntext = \"Ruby is awesome Ruby is powerful\"\nputs word_frequencies(text)<\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>merge<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u65b0\u3057\u3044\u30cf\u30c3\u30b7\u30e5\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u5143\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u5909\u66f4\u305b\u305a\u3001\u526f\u4f5c\u7528\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-28\">\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u9ad8\u3081\u308b\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-29\">1. <strong>\u660e\u78ba\u306a\u5909\u6570\u540d\u3092\u4f7f\u7528\u3059\u308b<\/strong><\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   # \u60aa\u3044\u4f8b\n   result = numbers.inject(0) { |a, b| a + b }\n\n   # \u826f\u3044\u4f8b\n   sum = numbers.inject(0) { |accumulator, number| accumulator + number }<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-30\">2. <strong>\u8907\u96d1\u306a\u51e6\u7406\u306f\u5225\u30e1\u30bd\u30c3\u30c9\u306b\u62bd\u51fa\u3059\u308b<\/strong><\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   def calculate_total_score(scores)\n     scores.inject(0) { |total, score| total + calculate_weighted_score(score) }\n   end\n\n   def calculate_weighted_score(score)\n     # \u8907\u96d1\u306a\u30b9\u30b3\u30a2\u8a08\u7b97\u30ed\u30b8\u30c3\u30af\n   end<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-31\">3. <strong>\u521d\u671f\u5024\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a\u3059\u308b<\/strong><\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   # \u60aa\u3044\u4f8b\uff08\u521d\u671f\u5024\u304c\u4e0d\u660e\u78ba\uff09\n   product = numbers.inject { |prod, n| prod * n }\n\n   # \u826f\u3044\u4f8b\n   product = numbers.inject(1) { |prod, n| prod * n }<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-32\">4. <strong>\u30b7\u30f3\u30dc\u30eb\u30b7\u30e7\u30fc\u30c8\u30ab\u30c3\u30c8\u3092\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b<\/strong><\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   # \u5358\u7d14\u306a\u64cd\u4f5c\u306e\u5834\u5408\n   sum = numbers.inject(:+)\n   product = numbers.inject(:*)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-33\">\u30c1\u30fc\u30e0\u958b\u767a\u3067\u306e\u6ce8\u610f\u70b9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306e\u7d71\u4e00<\/strong>\uff1a<code>inject<\/code>\u306e\u4f7f\u7528\u65b9\u91dd\u3092\u30c1\u30fc\u30e0\u3067\u6c7a\u5b9a\u3057\u3001\u4e00\u8cab\u6027\u3092\u4fdd\u3064\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u306e\u91cd\u8996<\/strong>\uff1a<code>inject<\/code>\u306e\u4f7f\u7528\u304c\u9069\u5207\u304b\u3069\u3046\u304b\u3092\u3001\u30c1\u30fc\u30e0\u3067\u78ba\u8a8d\u3059\u308b\u3002<\/li>\n\n\n\n<li><strong>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3<\/strong>\uff1a\u8907\u96d1\u306a<code>inject<\/code>\u306e\u4f7f\u7528\u306b\u306f\u3001\u30b3\u30e1\u30f3\u30c8\u3084\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u8aac\u660e\u3092\u4ed8\u3051\u308b\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-34\">\u4e00\u822c\u7684\u306a\u843d\u3068\u3057\u7a74\u3068\u56de\u907f\u7b56<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u904e\u4fe1<\/strong>\uff1a\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u306f\u3001<code>each<\/code>\u3068\u306e\u6bd4\u8f03\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3092\u53d6\u308b\u3002<\/li>\n\n\n\n<li><strong>\u904e\u5ea6\u306e\u8907\u96d1\u5316<\/strong>\uff1a\u4e00\u3064\u306e<code>inject<\/code>\u3067\u8907\u96d1\u306a\u51e6\u7406\u3092\u884c\u308f\u305a\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u51e6\u7406\u3092\u5206\u5272\u3059\u308b\u3002<\/li>\n\n\n\n<li><strong>\u521d\u671f\u5024\u306e\u8aa4\u308a<\/strong>\uff1a\u7279\u306b\u7a7a\u306e\u914d\u5217\u3092\u51e6\u7406\u3059\u308b\u5834\u5408\u3001\u9069\u5207\u306a\u521d\u671f\u5024\u306e\u8a2d\u5b9a\u3092\u5fd8\u308c\u305a\u306b\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">## \u60aa\u3044\u4f8b\uff08\u7a7a\u914d\u5217\u3067\u30a8\u30e9\u30fc\uff09\n[].inject { |max, n| [max, n].max }\n\n## \u826f\u3044\u4f8b\n[].inject(nil) { |max, n| max.nil? ? n : [max, n].max }<\/pre>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u5f37\u529b\u3067\u3059\u304c\u3001\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<br>\u3053\u308c\u3089\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u610f\u8b58\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u8aad\u307f\u3084\u3059\u304f\u3001\u4fdd\u5b88\u6027\u306e\u9ad8\u3044Ruby\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u308a\u9ad8\u5ea6\u306a<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u4f7f\u7528\u65b9\u6cd5\u306b\u3064\u3044\u3066\u63a2\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-35\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">6. \u4e0a\u7d1a\u8005\u5411\u3051\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3068\u62e1\u5f35<\/span><\/span><\/h2>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u6cd5\u3092\u7406\u89e3\u3057\u305f\u3089\u3001\u6b21\u306f\u3088\u308a\u9ad8\u5ea6\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3092\u63a2\u6c42\u3059\u308b\u6642\u3067\u3059\u3002<br>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3001\u62e1\u5f35\u3059\u308b\u65b9\u6cd5\u3092\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-36\">\u72ec\u81ea\u306eEnumerable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067inject\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b<\/h3>\n\n\n\n<p>\u30ab\u30b9\u30bf\u30e0\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u969b\u3001<code>Enumerable<\/code>\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u3053\u3068\u3067\u3001<code>inject<\/code>\u3092\u542b\u3080\u591a\u304f\u306e\u30a4\u30c6\u30ec\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3067\u304d\u307e\u3059\u3002<br>\u305f\u3060\u3057\u3001<code>each<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001\u4e8c\u5206\u6728\u69cb\u9020\u306b\u5bfe\u3057\u3066<code>inject<\/code>\u3092\u5b9f\u88c5\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class BinaryTree\n  include Enumerable\n\n  attr_reader :value, :left, :right\n\n  def initialize(value, left = nil, right = nil)\n    @value = value\n    @left = left\n    @right = right\n  end\n\n  def each(&amp;block)\n    left.each(&amp;block) if left\n    yield value\n    right.each(&amp;block) if right\n  end\nend\n\n## \u4f7f\u7528\u4f8b\ntree = BinaryTree.new(4,\n  BinaryTree.new(2, BinaryTree.new(1), BinaryTree.new(3)),\n  BinaryTree.new(6, BinaryTree.new(5), BinaryTree.new(7))\n)\n\nsum = tree.inject(0) { |acc, val| acc + val }\nputs sum  # \u51fa\u529b: 28<\/pre>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u4e8c\u5206\u6728\u69cb\u9020\u306b\u5bfe\u3057\u3066<code>inject<\/code>\u3092\u542b\u3080\u5168\u3066\u306e<code>Enumerable<\/code>\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u7528\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-37\">\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3068inject\u30e1\u30bd\u30c3\u30c9\uff1a\u52d5\u7684\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u751f\u6210\u3059\u308b<\/h3>\n\n\n\n<p>\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001<code>inject<\/code>\u306e\u52d5\u4f5c\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u52d5\u7684\u306b\u751f\u6210\u3067\u304d\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u914d\u5217\u306e\u8981\u7d20\u306b\u5bfe\u3057\u3066\u4efb\u610f\u306e\u6f14\u7b97\u3092\u884c\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u52d5\u7684\u306b\u5b9a\u7fa9\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Array\n  OPERATIONS = [:sum, :product, :max, :min]\n\n  OPERATIONS.each do |operation|\n    define_method(operation) do\n      case operation\n      when :sum\n        inject(0, :+)\n      when :product\n        inject(1, :*)\n      when :max\n        inject { |max, n| [max, n].max }\n      when :min\n        inject { |min, n| [min, n].min }\n      end\n    end\n  end\nend\n\nnumbers = [1, 2, 3, 4, 5]\nputs numbers.sum      # \u51fa\u529b: 15\nputs numbers.product  # \u51fa\u529b: 120\nputs numbers.max      # \u51fa\u529b: 5\nputs numbers.min      # \u51fa\u529b: 1<\/pre>\n\n\n\n<p>\u3053\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u306b\u3088\u308a\u3001\u30b3\u30fc\u30c9\u306e\u91cd\u8907\u3092\u6e1b\u3089\u3057\u3064\u3064\u3001<code>inject<\/code>\u306e\u6a5f\u80fd\u3092\u62e1\u5f35\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u7c21\u5358\u306b\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-38\">C\u8a00\u8a9e\u62e1\u5f35\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6975\u9650\u307e\u3067\u9ad8\u3081\u308b<\/h3>\n\n\n\n<p>\u7279\u306b\u9ad8\u3044\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u8981\u6c42\u3055\u308c\u308b\u5834\u5408\u3001C\u8a00\u8a9e\u62e1\u5f35\u3092\u4f7f\u7528\u3057\u3066<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u72ec\u81ea\u5b9f\u88c5\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001\u6574\u6570\u306e\u914d\u5217\u306b\u5bfe\u3059\u308b<code>sum<\/code>\u30e1\u30bd\u30c3\u30c9\u3092C\u62e1\u5f35\u3067\u5b9f\u88c5\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">##include &lt;ruby.h&gt;\n\nstatic VALUE rb_array_sum(VALUE self) {\n    long i, len = RARRAY_LEN(self);\n    VALUE *ptr = RARRAY_PTR(self);\n    long long sum = 0;\n\n    for (i = 0; i &lt; len; i++) {\n        sum += NUM2LL(ptr[i]);\n    }\n\n    return LL2NUM(sum);\n}\n\nvoid Init_fast_sum() {\n    rb_define_method(rb_cArray, \"fast_sum\", rb_array_sum, 0);\n}<\/pre>\n\n\n\n<p>\u3053\u306eC\u62e1\u5f35\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u306a\u914d\u5217\u306b\u5bfe\u3059\u308b\u5408\u8a08\u8a08\u7b97\u3092\u9ad8\u901f\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">require 'fast_sum'\n\nlarge_array = (1..1_000_000).to_a\nputs large_array.fast_sum  # \u51fa\u529b: 500000500000 (\u975e\u5e38\u306b\u9ad8\u901f)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-39\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5<\/h3>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u9ad8\u5ea6\u306a\u6280\u8853\u3092\u9069\u7528\u3059\u308b\u969b\u306f\u3001\u4ee5\u4e0b\u306e\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3092\u8003\u616e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b9f\u88c5\u306e\u8907\u96d1\u3055 vs \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/strong>: C\u62e1\u5f35\u306f\u9ad8\u901f\u3067\u3059\u304c\u3001\u5b9f\u88c5\u3068\u4fdd\u5b88\u304c\u8907\u96d1\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u67d4\u8edf\u6027 vs \u6700\u9069\u5316<\/strong>: \u7279\u5b9a\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u6700\u9069\u5316\u3059\u308b\u3068\u3001\u6c4e\u7528\u6027\u304c\u4f4e\u4e0b\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u958b\u767a\u6642\u9593 vs \u5b9f\u884c\u6642\u9593<\/strong>: \u9ad8\u5ea6\u306a\u6700\u9069\u5316\u306f\u958b\u767a\u6642\u9593\u3092\u5897\u52a0\u3055\u305b\u307e\u3059\u304c\u3001\u5b9f\u884c\u6642\u9593\u3092\u77ed\u7e2e\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-40\">\u5c06\u6765\u306e\u5c55\u671b\u3068\u7d99\u7d9a\u7684\u5b66\u7fd2<\/h3>\n\n\n\n<p>Ruby \u306e\u5c06\u6765\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306f\u3001JIT (Just-In-Time) \u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u6539\u5584\u3084\u3001\u3088\u308a\u52b9\u7387\u7684\u306a\u30e1\u30e2\u30ea\u7ba1\u7406\u306a\u3069\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u304c\u671f\u5f85\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u3053\u308c\u306b\u3088\u308a\u3001<code>inject<\/code>\u3092\u542b\u3080\u591a\u304f\u306e\u64cd\u4f5c\u304c\u81ea\u52d5\u7684\u306b\u6700\u9069\u5316\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7d99\u7d9a\u7684\u306b\u5b66\u7fd2\u3092\u9032\u3081\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/ruby-doc.org\/\">Ruby\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/rubykaigi.org\/\">RubyKaigi<\/a> \u306a\u3069\u306e\u30ab\u30f3\u30d5\u30a1\u30ec\u30f3\u30b9\u8cc7\u6599<\/li>\n\n\n\n<li><a href=\"https:\/\/rubyweekly.com\/\">Ruby Weekly<\/a> \u306a\u3069\u306e\u30cb\u30e5\u30fc\u30b9\u30ec\u30bf\u30fc<\/li>\n\n\n\n<li>GitHub\u4e0a\u306e\u4eba\u6c17\u306eRuby\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/li>\n<\/ol>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3068\u62e1\u5f35\u306f\u3001Ruby\u306e\u6df1\u3044\u7406\u89e3\u3068\u9ad8\u5ea6\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30ad\u30eb\u3092\u8981\u3057\u307e\u3059\u304c\u3001\u305d\u308c\u306b\u3088\u3063\u3066\u5f97\u3089\u308c\u308b\u67d4\u8edf\u6027\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u5411\u4e0a\u306f\u3001\u8907\u96d1\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u5927\u304d\u306a\u4fa1\u5024\u3092\u3082\u305f\u3089\u3057\u307e\u3059\u3002<br>\u3053\u308c\u3089\u306e\u6280\u8853\u3092\u9069\u5207\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u5f37\u529b\u306aRuby\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u767a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-sgb-headings sgb-heading\" id=\"i-41\"><span class=\"sgb-heading__inner sgb-heading--type1 with-icon\" style=\"background-color:transparent;border-color:transparent;font-size:1.2em\"><i class=\"fa fa-check\" style=\"color:var(--wp--preset--color--sango-main)\"><\/i><span class=\"sgb-heading__text\" style=\"color:#333\">7. \u307e\u3068\u3081\uff1ainject\u30e1\u30bd\u30c3\u30c9\u30de\u30b9\u30bf\u30fc\u3078\u306e\u9053<\/span><\/span><\/h2>\n\n\n\n<p>\u3053\u3053\u307e\u3067\u3001Ruby\u306e<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066\u3001\u57fa\u790e\u304b\u3089\u5fdc\u7528\u3001\u3055\u3089\u306b\u306f\u9ad8\u5ea6\u306a\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067\u5e45\u5e83\u304f\u5b66\u3093\u3067\u304d\u307e\u3057\u305f\u3002<br>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u307e\u3067\u306e\u5185\u5bb9\u3092\u632f\u308a\u8fd4\u308a\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u30de\u30b9\u30bf\u30fc\u306b\u306a\u308b\u305f\u3081\u306e\u9053\u7b4b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">inject\u30e1\u30bd\u30c3\u30c9\u306e\u5f37\u307f\u3092\u6700\u5927\u9650\u306b\u6d3b\u304b\u3059\u305f\u3081\u306e3\u3064\u306e\u9ec4\u91d1\u5247<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u9069\u6750\u9069\u6240\u306e\u539f\u5247<\/strong>: <code>inject<\/code>\u306f\u5f37\u529b\u3067\u3059\u304c\u3001\u5e38\u306b\u6700\u9069\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002\u30bf\u30b9\u30af\u306e\u6027\u8cea\u3092\u898b\u6975\u3081\u3001\u9069\u5207\u306a\u5834\u9762\u3067\u4f7f\u7528\u3057\u307e\u3057\u3087\u3046\u3002<\/li>\n\n\n\n<li><strong>\u53ef\u8aad\u6027\u91cd\u8996\u306e\u539f\u5247<\/strong>: \u8907\u96d1\u306a\u51e6\u7406\u306f\u5225\u30e1\u30bd\u30c3\u30c9\u306b\u62bd\u51fa\u3057\u3001\u660e\u78ba\u306a\u5909\u6570\u540d\u3092\u4f7f\u7528\u3059\u308b\u306a\u3069\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3092\u5e38\u306b\u610f\u8b58\u3057\u307e\u3057\u3087\u3046\u3002<\/li>\n\n\n\n<li><strong>\u6700\u9069\u5316\u3068\u6c4e\u7528\u6027\u306e\u30d0\u30e9\u30f3\u30b9\u306e\u539f\u5247<\/strong>: \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u8ffd\u6c42\u306f\u91cd\u8981\u3067\u3059\u304c\u3001\u30b3\u30fc\u30c9\u306e\u67d4\u8edf\u6027\u3068\u4fdd\u5b88\u6027\u3068\u306e\u30d0\u30e9\u30f3\u30b9\u3092\u53d6\u308b\u3053\u3068\u3092\u5fd8\u308c\u305a\u306b\u3002<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u539f\u5247\u3092\u610f\u8b58\u3059\u308b\u3053\u3068\u3067\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3057\u3001\u30af\u30ea\u30fc\u30f3\u3067\u52b9\u7387\u7684\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-42\">\u3055\u3089\u306a\u308b\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9\uff1ainject\u30e1\u30bd\u30c3\u30c9\u306e\u7406\u89e3\u3092\u6df1\u3081\u308b\u305f\u3081\u306e\u63a8\u5968\u66f8\u7c4d\u3068\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-43\">1. \u66f8\u7c4d<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u300cEffective Ruby\u300dby Peter J. Jones<\/li>\n\n\n\n<li>\u300cThe Well-Grounded Rubyist\u300dby David A. Black<\/li>\n\n\n\n<li>\u300cRuby Under a Microscope\u300dby Pat Shaughnessy<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-44\">2. \u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/ruby-doc.org\/\">Ruby\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.rubytapas.com\/\">RubyTapas<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/rubyweekly.com\/\">Ruby Weekly<\/a><\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30ea\u30bd\u30fc\u30b9\u306f\u3001<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u3060\u3051\u3067\u306a\u304f\u3001Ruby\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5168\u822c\u306e\u7406\u89e3\u3092\u6df1\u3081\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-45\">\u3042\u306a\u305f\u306eRuby\u30b9\u30ad\u30eb\u3092\u6b21\u306e\u30ec\u30d9\u30eb\u306b\u5f15\u304d\u4e0a\u3052\u308b\uff1a\u5b9f\u8df5\u7684\u306a\u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b9f\u8df5<\/strong>: \u5b66\u3093\u3060\u5185\u5bb9\u3092\u81ea\u5206\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u7a4d\u6975\u7684\u306b\u9069\u7528\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u5931\u6557\u3092\u6050\u308c\u305a\u306b\u6311\u6226\u3059\u308b\u3053\u3068\u304c\u3001\u771f\u306e\u7406\u89e3\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30fc\u30c9\u5206\u6790<\/strong>: \u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u3001<code>inject<\/code>\u306e\u4f7f\u7528\u4f8b\u3092\u63a2\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4ed6\u306e\u958b\u767a\u8005\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u304b\u3089\u5b66\u3076\u3053\u3068\u306f\u591a\u3044\u306f\u305a\u3067\u3059\u3002<\/li>\n\n\n\n<li><strong>\u6700\u9069\u5316\u306e\u63a2\u6c42<\/strong>: \u81ea\u5206\u306e\u30b3\u30fc\u30c9\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8a08\u6e2c\u3057\u3001<code>inject<\/code>\u3092\u4f7f\u3063\u305f\u6700\u9069\u5316\u306e\u6a5f\u4f1a\u3092\u898b\u3064\u3051\u307e\u3057\u3087\u3046\u3002\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3092\u53d6\u308a\u3001\u6539\u5584\u3092\u6570\u5024\u3067\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/li>\n\n\n\n<li><strong>\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5b66\u7fd2<\/strong>: <code>inject<\/code>\u306f\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6982\u5ff5\u3068\u5bc6\u63a5\u306b\u95a2\u9023\u3057\u3066\u3044\u307e\u3059\u3002\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u57fa\u672c\u3092\u5b66\u3076\u3053\u3068\u3067\u3001<code>inject<\/code>\u306e\u771f\u306e\u529b\u3092\u7406\u89e3\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u3078\u306e\u53c2\u52a0<\/strong>: Ruby\u306e\u30df\u30fc\u30c8\u30a2\u30c3\u30d7\u3084\u30ab\u30f3\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u53c2\u52a0\u3057\u3001\u4ed6\u306e\u958b\u767a\u8005\u3068\u77e5\u8b58\u3092\u5171\u6709\u3057\u307e\u3057\u3087\u3046\u3002\u6642\u306b\u306f\u6559\u3048\u308b\u3053\u3068\u304c\u6700\u826f\u306e\u5b66\u7fd2\u65b9\u6cd5\u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u30de\u30b9\u30bf\u30fc\u306b\u306a\u308b\u3053\u3068\u306f\u3001\u5358\u306b\u3072\u3068\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u7406\u89e3\u3059\u308b\u3060\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u308c\u306f\u3001Ruby\u306e\u54f2\u5b66\u3084\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6982\u5ff5\u3001\u3055\u3089\u306b\u306f\u30b3\u30fc\u30c9\u306e\u6700\u9069\u5316\u3084\u30af\u30ea\u30fc\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u539f\u5247\u306a\u3069\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5168\u822c\u306e\u30b9\u30ad\u30eb\u3092\u9ad8\u3081\u308b\u3053\u3068\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u305d\u306e\u5f37\u529b\u3055\u3068\u67d4\u8edf\u6027\u3086\u3048\u306b\u3001Ruby\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u5fc5\u9808\u30c4\u30fc\u30eb\u306e\u4e00\u3064\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br>\u3057\u304b\u3057\u3001\u305d\u306e\u771f\u4fa1\u3092\u767a\u63ee\u3059\u308b\u306b\u306f\u3001\u9069\u5207\u306a\u4f7f\u7528\u65b9\u6cd5\u3068\u3001\u4f7f\u7528\u3059\u3079\u304d\u5834\u9762\u3092\u898b\u6975\u3081\u308b\u5224\u65ad\u529b\u304c\u5fc5\u8981\u3067\u3059\u3002<br>\u3053\u306e\u8a18\u4e8b\u3067\u5b66\u3093\u3060\u5185\u5bb9\u3092\u57fa\u306b\u3001\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\u3067\u5b9f\u8df5\u3057\u3001\u8a66\u884c\u932f\u8aa4\u3092\u91cd\u306d\u308b\u3053\u3068\u3067\u3001\u3042\u306a\u305f\u306eRuby\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30ad\u30eb\u306f\u78ba\u5b9f\u306b\u5411\u4e0a\u3059\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5b66\u7fd2\u306b\u7d42\u308f\u308a\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br>\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306eRuby\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u308b\u305f\u3073\u306b\u3001\u65b0\u3057\u3044\u6a5f\u80fd\u3084\u6700\u9069\u5316\u306e\u65b9\u6cd5\u304c\u767b\u5834\u3057\u307e\u3059\u3002<br>\u5e38\u306b\u597d\u5947\u5fc3\u3092\u6301\u3061\u3001\u5b66\u3073\u7d9a\u3051\u308b\u59ff\u52e2\u3092\u5927\u5207\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p><code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u30de\u30b9\u30bf\u30fc\u3078\u306e\u9053\u306f\u3001\u6c7a\u3057\u3066\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u305d\u306e\u904e\u7a0b\u3067\u5f97\u3089\u308c\u308b\u77e5\u8b58\u3068\u7d4c\u9a13\u306f\u3001\u3042\u306a\u305f\u3092\u5353\u8d8a\u3057\u305fRuby\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u3078\u3068\u5c0e\u3044\u3066\u304f\u308c\u308b\u3067\u3057\u3087\u3046\u3002<br>\u3055\u3042\u3001\u3053\u3053\u307e\u3067\u5b66\u3093\u3060\u3053\u3068\u3092\u6d3b\u304b\u3057\u3066\u3001\u3042\u306a\u305f\u3060\u3051\u306e<code>inject<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u6d3b\u7528\u6cd5\u3092\u898b\u3064\u3051\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br>Ruby\u306e\u4e16\u754c\u306b\u306f\u3001\u307e\u3060\u307e\u3060\u63a2\u6c42\u3059\u3079\u304d\u591a\u304f\u306e\u53ef\u80fd\u6027\u304c\u5e83\u304c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>Happy coding, and may your <code>inject<\/code> always return the perfect result!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ruby\u306einject\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u914d\u5217\u3084\u30cf\u30c3\u30b7\u30e5\u306a\u3069\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u521d\u5fc3\u8005\u306b\u3068\u3063\u3066\u306f\u5c11\u3057\u96e3\u89e3\u306b\u611f\u3058\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u306a\u308c\u3070\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u52b9\u7387\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":3165,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,65,75],"tags":[],"class_list":{"0":"post-130","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-ruby","8":"category-ruby-syntax","9":"category-75"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/132"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/media\/3165"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}