{"id":4155,"date":"2018-06-15T22:36:40","date_gmt":"2018-06-15T13:36:40","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=4155"},"modified":"2020-10-24T10:19:24","modified_gmt":"2020-10-24T01:19:24","slug":"%e3%80%90ruby%e3%80%91%e5%9f%ba%e7%a4%8e%e7%9f%a5%e8%ad%98","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=4155","title":{"rendered":"\u3010Ruby\u3011\u6587\u5b57\u5217\u306b\u3064\u3044\u3066\u306e\u77e5\u8b58"},"content":{"rendered":"<h2>1\u6587\u306e\u533a\u5207\u308a<\/h2>\n<p>\u300c\u6539\u884c\u300d\u304c1\u6587\u306e\u533a\u5207\u308a\u306b\u306a\u308a\u307e\u3059\u3002\u3088\u304f\u3042\u308b<span style=\"color: #ff0000;\"><strong>\u30bb\u30df\u30b3\u30ed\u30f3(;)<\/strong><\/span>\u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3067\u3059\u3002<\/p>\n<h2>\u6587\u5b57\u5217<\/h2>\n<h3>\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3046<\/h3>\n<p>\u7279\u6b8a\u6587\u5b57\uff08\\n,\\r\u3001\\t\u7b49\uff09\u3092\u3001<span style=\"color: #ff0000;\"><strong>\u305f\u3060\u306e<\/strong><strong>\u6587\u5b57\u5217\u3068\u3057\u3066<\/strong><strong>\u6271\u3046<\/strong><\/span>\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h3>\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3046<\/h3>\n<p>\u7279\u6b8a\u6587\u5b57\uff08\\n,\\r\u3001\\t\u7b49\uff09\u3084\u5f0f\u5c55\u958b\u3082\u3001<span style=\"color: #ff0000;\"><strong>\u7279\u6b8a<\/strong><strong>\u6587\u5b57\u5217\u3068\u3057\u3066\u6271\u3046<\/strong><\/span>\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h4>\u5f0f\u5c55\u958b<\/h4>\n<p>\u4f8b\u3048\u3070\u3001name\u3068\u3044\u3046\u5909\u6570\u304c\u3042\u3063\u305f\u5834\u5408\u306b\u300c\"\u79c1\u306e\u540d\u524d\u306f#{name}\u3067\u3059\u3002\"\u300d\u3068\u3059\u308b\u3068<span style=\"color: #ff0000;\"><strong>\u6587\u5b57\u5217\u306e\u4e2d\u306b\u5909\u6570\u3092\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u6a5f\u80fd\u3067\u3059\u3002\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3063\u305f\u5834\u5408\u3057\u304b\u52d5\u4f5c\u3057\u306a\u3044\u306e\u3067\u6ce8\u610f<\/strong><\/span>\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u5b9f\u884c\u7d50\u679c\u6bd4\u8f03<\/h3>\n<pre class=\"lang:default decode:true\">str = 'Hello \\nWorld'\r\nputs str\r\n\r\nstr = \"Hello \\nWorld\"\r\nputs str<\/pre>\n<h4>\u00a0\u5b9f\u884c\u7d50\u679c<\/h4>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-4160\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"310\" height=\"75\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c.png 310w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/06\/\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3_\u5b9f\u884c\u7d50\u679c-300x73.png 300w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/p>\n<h3>\u300c\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u3068\u3001\u300c\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u306e\u4f7f\u3044\u5206\u3051<\/h3>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001\u300c\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u306a\u3044\u5834\u5408\u306f\u3001\u300c\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u3092\u4f7f\u3046\u3068\u3057\u3066\u3044\u308b\u73fe\u5834\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<h3>\u6587\u5b57\u5217\u306e\u51fa\u529b<\/h3>\n<p>\u6587\u5b57\u5217\u306e\u51fa\u529b\u306b\u306f\u3001\u4e0b\u8a18\u306e3\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>puts<\/li>\n<li>print<\/li>\n<li>p<\/li>\n<\/ul>\n<h4>puts<\/h4>\n<p>\u6539\u884c\u3092\u52a0\u3048\u3066\u3001\u6587\u5b57\u5217\u3092\u51fa\u529b\u3059\u308b\u3002\u8a55\u4fa1\u7d50\u679c\u3068\u3057\u3066nil\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h4>print<\/h4>\n<p>\u6539\u884c\u3092\u52a0\u3048\u305a\u306b\u3001\u6587\u5b57\u5217\u3092\u51fa\u529b\u3059\u308b\u3002\u8a55\u4fa1\u7d50\u679c\u3068\u3057\u3066nil\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h4>p<\/h4>\n<p>\u30c7\u30d0\u30c3\u30b0\u7528\u306b\u4f7f\u3046\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u305d\u306e\u3082\u306e\u3092\u8fd4\u3057\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5185\u5bb9\u3092\u898b\u3084\u3059\u3044\u3088\u3046\u306b\u6574\u5f62\u3057\u3066\u304f\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u6539\u884c\u3092\u52a0\u3048\u3066\u3055\u3089\u306b\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3093\u3067\u6587\u5b57\u5217\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<h4>pp<\/h4>\n<p>\u3053\u308c\u3082p\u30e1\u30bd\u30c3\u30c9\u3068\u540c\u3058\u3088\u3046\u306b\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002p\u30e1\u30bd\u30c3\u30c9\u306e\u51fa\u529b\u304c\u898b\u8f9b\u3044\u5834\u5408\u306f\u3053\u3061\u3089\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u30a8\u30b9\u30b1\u30fc\u30d7\u3059\u308b\u306b\u306f<\/h3>\n<p>\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3084\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u300c%q!\u300d\u3082\u3057\u304f\u306f\u300c%Q!\u300d\u3001\u300c%!\u300d\u3067\u6587\u5b57\u5217\u3092\u56f2\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">#\u300c%q!\u300d\uff1a\u30b7\u30f3\u30b0\u30eb\u30af\u30aa\u30fc\u30c8\u3067\u56f2\u3063\u305f\u3053\u3068\u3068\u540c\u3058\u306b\u306a\u308b\u3002\r\nputs %q!\"\u30c6\u30b9\u30c8\u3067\u3059\u30882\",'!\r\n\r\n#\u300c%Q!\u300d\u3001\u300c%!\u300d\uff1a\u30c0\u30d6\u30eb\u30af\u30aa\u30fc\u30c8\u3067\u56f2\u3063\u305f\u3053\u3068\u3068\u540c\u3058\u306b\u306a\u308b\u3002\r\nputs %Q!\"\u30c6\u30b9\u30c8\u3067\u3059\u30883\",'!\r\nputs %!\"\u30c6\u30b9\u30c8\u3067\u3059\u3088\",'!<\/pre>\n<h2>\u6587\u5b57\u306e\u9023\u7d50<\/h2>\n<h3>+\u6f14\u7b97\u5b50\u3092\u4f7f\u3063\u305f\u65b9\u6cd5<\/h3>\n<pre class=\"lang:default decode:true\">\"\u6587\u5b57\u3092\" + \"\u9023\u7d50\u3055\u305b\u308b\"<\/pre>\n<h4>\u9023\u7d50\u3055\u305b\u305f\u6587\u5b57\u5217\u3092\u4fdd\u6301\u3057\u305f\u3044\u5834\u5408\uff08\u81ea\u5df1\u4ee3\u5165\u3092\u4f7f\u3046\uff09<\/h4>\n<p>\u4e00\u65e6\u5909\u6570\u306b\u683c\u7d0d\u3057\u305f\u4e0a\u3067\u305d\u306e\u5909\u6570\u306b\u5bfe\u3057\u3066\u81ea\u5df1\u4ee3\u5165\u3092\u884c\u3044\u307e\u3059\u3002\u5de6\u306e\u5f0f\u304b\u3089\u8a55\u4fa1\u3055\u308c\u308b\u306e\u3067\u5909\u6570\u306b\u5024\u3092\u4ee3\u5165\u3057\u3066\u3044\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">str += \"\u9023\u7d50\u3059\u308b\u3002\"<\/pre>\n<h3>\u672b\u5c3e\u306b\u8ffd\u8a18\u3059\u308b\u65b9\u6cd5<\/h3>\n<pre class=\"lang:default decode:true\">\"\u6587\u5b57\u306e\" &lt;&lt; \"\u672b\u5c3e\u306b\u8ffd\u52a0\u3059\u308b\u3002\"<\/pre>\n<h4>\u6587\u5b57\u3092\u7e70\u308a\u8fd4\u3059<\/h4>\n<p>\u6587\u5b57\u3092\u6307\u5b9a\u3057\u305f\u56de\u6570\u5206\u7e70\u308a\u8fd4\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5b9f\u52d9\u3067\u306f\u3042\u307e\u308a\u4f7f\u7528\u983b\u5ea6\u306f\u9ad8\u304f\u306a\u3044\u3067\u3059\u304c<span style=\"color: #ff0000;\"><strong>\u30c6\u30b9\u30c8\u3068\u304b\u3067\u6c7a\u307e\u3063\u305f\u6587\u5b57\u6570\u306e\u6587\u5b57\u3092\u4f5c\u308a\u305f\u3044\u5834\u5408\u7b49\u306b\u306f\u91cd\u5b9d<\/strong><\/span>\u3057\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">'\u6587\u5b57' * 10(\u7e70\u308a\u8fd4\u3057\u56de\u6570)<\/pre>\n<h2>\u30a4\u30f3\u30c7\u30f3\u30c8\uff08\u5b57\u4e0b\u3052\uff09<\/h2>\n<p>Ruby\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3001\u30a4\u30f3\u30c7\u30f3\u30c8\uff08\u5b57\u4e0b\u3052\uff09\u3059\u308b\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30bf\u30d6\u3092\u4f7f\u308f\u305a\u306b\u30b9\u30da\u30fc\u30b9\uff12\u3064\u3067\u30a4\u30f3\u30c7\u30f3\u30c8\u3059\u308b\u6c7a\u307e\u308a\u3068\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044<\/strong><\/span>\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"1\u6587\u306e\u533a\u5207\u308a \u300c\u6539\u884c\u300d\u304c1\u6587\u306e\u533a\u5207\u308a\u306b\u306a\u308a\u307e\u3059\u3002\u3088\u304f\u3042\u308b\u30bb\u30df\u30b3\u30ed\u30f3(;)\u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3067\u3059\u3002 \u6587\u5b57\u5217 \u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3046 \u7279\u6b8a\u6587\u5b57\uff08\\n,\\r\u3001\\t\u7b49\uff09\u3092\u3001\u305f\u3060\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002 \u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc [&hellip;]","protected":false},"author":1,"featured_media":4232,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4155"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4155"}],"version-history":[{"count":28,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4155\/revisions"}],"predecessor-version":[{"id":12046,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4155\/revisions\/12046"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4232"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4155"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}