{"id":5734,"date":"2015-04-10T03:34:13","date_gmt":"2015-04-09T18:34:13","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=5734"},"modified":"2015-04-10T03:43:45","modified_gmt":"2015-04-09T18:43:45","slug":"ruby%e3%82%92%e5%a7%8b%e3%82%81%e3%82%8b%e6%99%82%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=5734","title":{"rendered":"Ruby\u3092\u59cb\u3081\u308b\u6642\u306e\u307e\u3068\u3081\u3002"},"content":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p><strong>Ruby on Rails<\/strong>\u3067\u6700\u8fd1\u3082\u3063\u3071\u3089\u4f55\u304b\u3068\u8a71\u984c\u306e<strong>Ruby\u754c\u9688<\/strong>\u3002<\/p>\n<p><a href=\"https:\/\/www.ruby-lang.org\/ja\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2dee2f595cdf20ba8222c2de81a3a2e9.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-04-09 16.51.41\" width=\"349\" height=\"86\" class=\"alignnone size-full wp-image-5735\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2dee2f595cdf20ba8222c2de81a3a2e9.png 349w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2dee2f595cdf20ba8222c2de81a3a2e9-300x73.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/a><\/p>\n<p><strong>\u516c\u5f0f\u30b5\u30a4\u30c8<\/strong><\/p>\n<p><a href=\"https:\/\/www.ruby-lang.org\/ja\/\" target=\"_blank\">https:\/\/www.ruby-lang.org\/ja\/<\/a><\/p>\n<p>\u8a00\u308f\u305a\u3068\u77e5\u308c\u305f\u3001<strong>\u300c\u307e\u3064\u3082\u3068\u3086\u304d\u3072\u308d\uff08\u901a\u79f0 Matz\uff09\u3055\u3093\u300d<\/strong>\u304c\u958b\u767a\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3092\u7528\u3044\u305f\u56fd\u7523\u306e\u8a00\u8a9e\u3067\u3059\u306d\u3002<\/p>\n<p>\u3068\u3001\u3075\u3068Ruby\u3092\u66f8\u304d\u305f\u304f\u306a\u3063\u305f\u306e\u3067\u3001\u66f8\u3053\u3046\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u666e\u6bb5\u65e5\u5e38\u7684\u306b\u306f\u66f8\u304b\u306a\u3044\u306e\u3067<\/p>\n<p>\u300c\u3042\u308c\u3001\u3069\u3093\u306a\u3060\u3063\u3051\u300d\u73fe\u8c61\u3002<\/p>\n<p>\u6700\u8fd1\u306fPHP\u3084 TypeScript\u3084 C\u8a00\u8a9e\u306a\u3093\u304b\u3068\u8272\u3005\u66f8\u3044\u305f\u308a\u3057\u3066\u3044\u3066\u3082\u3046\u3001\u3069\u308c\u304c\u3069\u3046\u3060\u3063\u305f\u304bw<\/p>\n<p>\u3068\u3001\u81ea\u5206\u306e\u904e\u53bb\u8a18\u4e8b\u3092\u6f01\u308b\u3002<\/p>\n<h3><a href=\"https:\/\/www.webcyou.com\/?p=4915\">Ruby \u57fa\u672c\u307e\u3068\u3081<\/a><\/h3>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=4915\" target=\"_blank\">https:\/\/www.webcyou.com\/?p=4915<\/a><\/p>\n<p><strong>\u8d85\u308f\u304b\u308a\u305a\u3089\u3044\u3002<\/strong><\/p>\n<p><strong>Interactive Ruby<\/strong>\u3067\u3084\u3063\u3066\u308b\u306e\u3067\u308f\u304b\u308a\u305a\u3089\u3044\u308f\u3002<\/p>\n<p>\u3056\u3063\u3068\u66f8\u3044\u305f\u611f\u304c\u4e38\u51fa\u3057\u3067\u3057\u305f\u306d\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u56f0\u3063\u305f\u6642\u306e\u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff01\uff01w<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da.png\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-04-09 17.05.54\" width=\"512\" height=\"204\" class=\"alignnone  wp-image-5736\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da.png 732w, https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da-300x119.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p><strong>\u516c\u5f0f\u30b5\u30a4\u30c8<\/strong><\/p>\n<p><a href=\"http:\/\/dotinstall.com\/\" target=\"_blank\">http:\/\/dotinstall.com\/<\/a><\/p>\n<p><strong>Ruby<\/strong><\/p>\n<p><a href=\"http:\/\/dotinstall.com\/lessons\/basic_ruby_v2\/\" target=\"_blank\">http:\/\/dotinstall.com\/lessons\/basic_ruby_v2\/<\/a><\/p>\n<p>\u3046\u3093\u3002\u3084\u3063\u3071\u308a\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u308f\uff01\uff01\uff01w<\/p>\n<p>\u3068\u3044\u3046\u304b\u3001\u7530\u53e3\u3055\u3093\u30d5\u30eb\u30b9\u30bf\u30c3\u30af\u3059\u304e\u307e\u3059\u306d\u3002\u3044\u3084\u30fc\u3059\u3054\u3044\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u521d\u5fc3\u8005\u3067\u3082\u30b5\u30af\u30c3\u3068\u5165\u308c\u308b\u3088\u3046\u306b\u3001\u8981\u70b9\u3092\u307e\u3068\u3081\u6587\u66f8\u306b\u8d77\u3053\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h4>Ruby<\/h4>\n<h5>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h5>\n<p><strong>mac<\/strong><\/p>\n<p>Ruby 2.0.0 \u306f OS X Mavericks \u306b\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>brew\u3092\u4f7f\u3063\u305f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">brew install ruby<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>win<\/strong><\/p>\n<p>windows\u306e\u65b9\u306f<strong>RubyInstaller<\/strong>\u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u826f\u3055\u3052\u3067\u3059\u306d\u3002<\/p>\n<p><a href=\"http:\/\/rubyinstaller.org\/\" target=\"_blank\">http:\/\/rubyinstaller.org\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">ruby -v<\/pre>\n<p>\u62e1\u5f35\u5b50\u306f\u300c.rb\u300d<\/p>\n<h5><strong>\u51fa\u529b<\/strong><\/h5>\n<p><strong>\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">#<\/pre>\n<p><strong>\u6539\u884c\u306a\u3057<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">print<\/pre>\n<p><strong>\u6539\u884c\u3042\u308a<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">puts<\/pre>\n<p><strong>\u30c7\u30fc\u30bf\u5f62\u5f0f\u8868\u793a<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p<\/pre>\n<p>\u4f8b:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">print \"hello world!\"\r\nputs \"hello world(puts)\"\u00a0\r\np \"hello world(p)\"<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">hello world!hello world(puts)\"hello world(p)\"<\/pre>\n<h4>\u5909\u6570\u30fb\u5b9a\u6570<\/h4>\n<p><strong>\u5909\u6570\u306f\u5c0f\u6587\u5b57<\/strong>\u59cb\u307e\u308a\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">msg = \"hello world\"<\/pre>\n<p><strong>\u5b9a\u6570\u306f\u5927\u6587\u5b57<\/strong>\u59cb\u307e\u308a\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">WEBCYOU_URL = \"https:\/\/www.webcyou.com\/\"<\/pre>\n<p><strong>\u5b9a\u6570\u5b9a\u7fa9\u5f8c\u306b\u5909\u66f4\u884c\u3046\u3068warning \u8868\u793a\u3002<\/strong><\/p>\n<h4>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3001\u30e1\u30bd\u30c3\u30c9\u3001\u30af\u30e9\u30b9<\/h4>\n<h5>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h5>\n<p>Ruby\u306e\u30c7\u30fc\u30bf\u306f\u3059\u3079\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3044\u3046\u3053\u3068\u3067\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p \"hello world\".length<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u6271\u3046\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\uff11\uff11<\/pre>\n<p>\u3068\u3001\u8868\u793a\u3002<\/p>\n<p>\u3053\u306e\u8fba\u3082\u3001Ruby\u306a\u3089\u3067\u306f\u3067\u300c\u304a\u3049\u30fc\u30fc\u300d\u3068\u306a\u308a\u307e\u3059\u3088\u306d\u3002<\/p>\n<h5>\u30e1\u30bd\u30c3\u30c9<\/h5>\n<p>\u7d44\u307f\u8fbc\u307f\u30e1\u30bd\u30c3\u30c9\u306f\u5168\u3066\u30af\u30e9\u30b9\u3067\u4f5c\u3089\u308c\u3066\u3044\u308b\u3002<\/p>\n<p><strong>\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u8a18\u8f09\u3057\u3066\u3044\u308b<\/strong><\/p>\n<p><a href=\"http:\/\/ruby-doc.org\/core-2.2.1\/\" target=\"_blank\">http:\/\/ruby-doc.org\/core-2.2.1\/<\/a><\/p>\n<h4>\u6570\u5024\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 -Numeric<\/h4>\n<p>\u6574\u6570\b\u5024\u3001\u5b9f\u6570\u5024\u306f\u3082\u3061\u308d\u3093\u5206\u6570\u5024\u3082\u6271\u3048\u3061\u3083\u3046Ruby\u306e\u6570\u5024\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/p>\n<p>\u3055\u3089\u306b\u3001\u300c_\u300d\u3092\u7121\u8996\u3059\u308b\u3068\u3044\u3063\u305f\u4ed5\u69d8\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">x = 10_000_000\r\np x<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">10000000<\/pre>\n<p>\u3053\u308c\u3082\u5909\u308f\u3063\u3066\u3044\u307e\u3059\u3088\u306d\u30fc\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3042\u3068\u3001\u7d2f\u4e57\u306f\u300c**\u300d\u3067\u4f7f\u7528\u53ef\u80fd<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p 10 ** 3<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">1000<\/pre>\n<p>\u66f4\u306b\u5206\u6570\u5024\u3082<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p 1\/3r * 2<\/pre>\n<p>1\/3r\u306f \u6709\u7406\u6570\uff08Rational\uff09\u306e\u7701\u7565\u3067Rational(1, 3)\u3068\u540c\u69d8\u3001<\/p>\n<p><code>Rational<\/code>\u30af\u30e9\u30b9\u3092\u7701\u7565\u3057\u3066\u4f7f\u3048\u308b\u307f\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p><strong>\u201cr\u201d\u30b5\u30d5\u30a3\u30c3\u30af\u30b9<\/strong>\u306f\u3069\u3046\u3084\u3089<strong>ruby \u30d0\u30fc\u30b8\u30e7\u30f32.1\u301c \u4f7f\u7528\u53ef\u80fd<\/strong>\u3067\u3001<strong>ruby \u30d0\u30fc\u30b8\u30e7\u30f32.0\u3060\u3068\u30a8\u30e9\u30fc<\/strong>\u3067\u3057\u305f\u3002<\/p>\n<p><strong>ruby \u30d0\u30fc\u30b8\u30e7\u30f32.1\u4ee5\u4e0b<\/strong>\u306e\u65b9\u306f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p Rational(1, 3) * 2<\/pre>\n<p>\u3068\u3044\u3063\u305f\u5f62\u3067\u5206\u6570\u5024\u3092\u6c42\u3081\u308b\u304b\u3068\u3002<\/p>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">(2\/3)<\/pre>\n<p>\u6570\u5024\u306b\u95a2\u3057\u3066\u3082\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\u306e\u3067\u3001\u5b9f\u6570\u5024\u3092\u4e38\u3081\u308b\u969b<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">y = 20.5<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p y.round<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">21<\/pre>\n<p>\u3068\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u7b49\u306b\u95a2\u3057\u3066\u306f\u3001\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306eNumeric\u30af\u30e9\u30b9\u3092\u53c2\u7167\u3002<\/p>\n<p>\uff08\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.2.0\uff09<\/p>\n<p><a href=\"http:\/\/ruby-doc.org\/core-2.2.0\/Numeric.html\" target=\"_blank\">http:\/\/ruby-doc.org\/core-2.2.0\/Numeric.html<\/a><\/p>\n<h4>\u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 -String<\/h4>\n<p>\u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f<strong>\u300c&#8221; &#8220;\u300d<\/strong>\u304b<strong>\u300c&#8217; &#8216;\u300d<\/strong>\u3067\u56f2\u3046\u3053\u3068\u3067\u751f\u6210\u3002<\/p>\n<p>\u7279\u5fb4\u3068\u3057\u3066<strong>\u300c&#8221; &#8220;\u300d<\/strong>\u306f<strong>\u5909\u6570\u5c55\u958b\u3059\u308b\u3053\u3068\u3068\u3001\u7279\u6b8a\u6587\u5b57\u3092\u6271\u3046\u3053\u3068<\/strong>\u304c\u3067\u304d\u308b\u3002<\/p>\n<p><strong>\u300c&#8217; &#8216;\u300d<\/strong>\u306f\u4e0d\u53ef\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">name = \"takayama\"x = \"hello world, #{name}\"\r\ny = 'hello world, {name}'puts x\r\nputs y<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">hello world, takayamahello world, {name}<\/pre>\n<p><strong>\u7279\u6b8a\u6587\u5b57<\/strong><\/p>\n<p>\u30bf\u30d6\u30b3\u30fc\u30c9\uff08\\t \uff09\u3084\u6539\u884c\u30b3\u30fc\u30c9\uff08\\n\uff09\u3082<strong>\u300c&#8221; &#8220;\u300d<\/strong>\u306f<strong>\u5c55\u958b\u304c\u53ef\u80fd<\/strong>\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3042\u3068\u4fbf\u5229\u306a\u306e\u304c\u6587\u5b57\u5217\u306e\u7e70\u308a\u8fd4\u3057\u3082<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">puts \"web\u5e33 \" * 5<\/pre>\n<p>\u3053\u308c\u3067\u53ef\u80fd\u3067\u3059\u306d\u3002<\/p>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">web\u5e33\r\nweb\u5e33\r\nweb\u5e33\r\nweb\u5e33\r\nweb\u5e33<\/pre>\n<p>\u305d\u306e\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u7b49\u306b\u95a2\u3057\u3066\u306f\u3001\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306eString\u30af\u30e9\u30b9\u3092\u53c2\u7167\u3002<\/p>\n<p>\uff08\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.2.0\uff09<\/p>\n<p><a href=\"http:\/\/ruby-doc.org\/core-2.2.0\/String.html\" target=\"_blank\">http:\/\/ruby-doc.org\/core-2.2.0\/String.html<\/a><\/p>\n<h4>\u7834\u58ca\u7684\u30e1\u30bd\u30c3\u30c9\u3001\u771f\u507d\u5024\u3092\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9<\/h4>\n<p><strong>\u7834\u58ca\u7684\u30e1\u30bd\u30c3\u30c9<\/strong><\/p>\n<p>\u901a\u5e38<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">s = \"webcyou\"\r\nputs s.upcase\r\nputs s<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">WEBCYOU\r\nwebcyou<\/pre>\n<p>\u300c!\u300d\u3092\u3064\u3051\u308b\u3068\u7834\u58ca\u7684\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5909\u66f4\u53ef\u80fd<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">s = \"webcyou\"\r\nputs s.upcase!\r\nputs s<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">WEBCYOU\r\nWEBCYOU<\/pre>\n<p><strong>\u771f\u507d\u5024\u30e1\u30bd\u30c3\u30c9<\/strong><\/p>\n<p>\u300c?\u300d\u3092\u4ed8\u4e0e\u3059\u308b\u3068\u771f\u507d\u5024\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">s = \"\"\r\np s.empty? # true<\/pre>\n<h4>\u914d\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h4>\n<p>ruby\u306e\u914d\u5217\u306e\u7279\u5fb4\u3068\u3057\u3066<\/p>\n<h5>\u6dfb\u3048\u5b57\u3067\u7bc4\u56f2\u6307\u5b9a\u300c..\u300d<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\np num&#x5B;0..2]<\/pre>\n<p>result<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;5, 8, 4]<\/pre>\n<h5>\u6dfb\u3048\u5b57\u3067\u7bc4\u56f2\u6307\u5b9a\u300c&#8230;\u300d<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\np num&#x5B;0...2]<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;5, 8]<\/pre>\n<h5>\u8ca0\u306e\u5024\u3067\u914d\u5217\u6700\u5f8c\u306e\u5024\u53d6\u5f97<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\np num&#x5B;-1]<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">4<\/pre>\n<h5>\u8907\u6570\u53d6\u5f97\u300c,\u300d<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\np num&#x5B;1,2]<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;8,4]<\/pre>\n<h5>\u7bc4\u56f2\u6307\u5b9a\u306e\u7f6e\u63db<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\nnum&#x5B;0...2] = &#x5B;1,2]\r\np num<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;1, 2, 4]<\/pre>\n<h5>\u8907\u6570\u633f\u5165<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\nnum&#x5B;1,0] = &#x5B;10,11,12]\r\np num<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;5, 10, 11, 12, 8, 4]<\/pre>\n<p>\u300c1,0\u300d\u306f1\u756a\u76ee\u306e0\u500b\u5206\u3092\u610f\u5473\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u300c1,1\u300d= [10,11,12]\u3068\u3059\u308b\u3068\u30018\u304c\u7f6e\u63db\u3055\u308c\u3001<\/p>\n<p>[5, 10, 11, 12, 4] \u3068\u306a\u308b\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u4fbf\u5229\u3068\u3044\u3046\u304b\u3001Ruby\u306e\u67d4\u8edf\u6027\u306e\u9ad8\u3055\u3002<\/p>\n<h5>\u7bc4\u56f2\u6307\u5b9a\u306e\u524a\u9664<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\nnum&#x5B;0,2] = &#x5B;]\r\np num<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;4]<\/pre>\n<p>\u3053\u308c\u3082\u307e\u305f\u3001Ruby\u306a\u3089\u3067\u306f\u306e\u7279\u6b8a\u306a\u8a18\u8ff0\u306e\u4ed5\u65b9\u3002<\/p>\n<p>\u300c0,2\u300d0\u756a\u76ee\u304b\u30892\u500b\u5206\u3092\u300c[]\u300d\u7a7a\u306b\u3002<\/p>\n<p>\u4ed6\u8a00\u8a9e\u3068\u6bd4\u8f03\u3057\u3066\u3001\u3088\u308a\u76f4\u611f\u7684\u306b\u8a18\u8ff0\u3057\u3066\u3044\u3051\u308b\u611f\u3058\u3067\u3059\u306d\u3002<\/p>\n<p><strong>\u30e1\u30bd\u30c3\u30c9<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\np num.size\r\np num.sort<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">3\r\n&#x5B;4, 5, 8]<\/pre>\n<p>.sort\u3067\u30bd\u30fc\u30c8\u304c\u53ef\u80fd\u306a\u4fbf\u5229\u3055\u3002<\/p>\n<p>\u66f4\u306b\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3082\u300c.\u300d\u3064\u306a\u304e\u3067\u53ef\u80fd<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num.sort.reverse<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;8, 5, 4]<\/pre>\n<p>\u305d\u306e\u4ed6\u3001\u914d\u5217\u306b\u8ffd\u52a0\u3059\u308bpush\u3092\u7701\u7565\u3057\u3066\u300c&lt;&lt;\u300d\u3092\u7528\u3044\u3066\u5229\u7528\u53ef\u80fd\u3067\u3001\u8907\u6570\u8ffd\u52a0\u3082\u884c\u3048\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">num = &#x5B;5, 8, 4]\r\nnum\u00a0&lt;&lt; 100 &lt;&lt; 102\r\np num<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;5, 8, 4, 100, 102]<\/pre>\n<p>\u305d\u306e\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u7b49\u306b\u95a2\u3057\u3066\u306f\u3001\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306eArray\u30af\u30e9\u30b9\u3092\u53c2\u7167\u3002<\/p>\n<p>\uff08\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.2.0\uff09<\/p>\n<p><a href=\"http:\/\/ruby-doc.org\/core-2.2.0\/Array.html\" target=\"_blank\">http:\/\/ruby-doc.org\/core-2.2.0\/Array.html<\/a><\/p>\n<p>\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u30d1\u30c3\u3068\u307f\u3066\u3001\u76ee\u306b\u5165\u3063\u305f\u3084\u3064\u3067\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">hoge = Array.new(3, true);\r\np hoge<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;true, true, true]<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u8907\u6570\u914d\u5217\u751f\u6210\u3082\u3067\u304d\u308b\u307f\u305f\u3044\u3067\u3001\u8d85\u697d\u3067\u3059\u306d\uff01<\/p>\n<h4>\u30cf\u30c3\u30b7\u30e5\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sales = {&quot;takayama&quot; =&gt; 200, &quot;webcyou&quot; =&gt; 300 }\r\np sales&#x5B;&quot;takayama&quot;]<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">200<\/pre>\n<p>\u307e\u30fc\u3053\u306e\u8fba\u306f\u826f\u3044\u3068\u3057\u3066\u3001Ruby\u306e\u7279\u5fb4\u304b\u3089 \u30b7\u30f3\u30dc\u30eb\u3068\u3057\u3066\u6271\u3046\u5834\u5408<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sales = {:takayama =&gt; 200, :webcyou =&gt; 300 }\r\np sales&#x5B;:takayama]<\/pre>\n<p>\u3068\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3068\u30b7\u30f3\u30dc\u30eb\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u53ef\u80fd\u3002<\/p>\n<p>\u307e\u305f\u3001Ruby1.9\u301c\u306f\u30b7\u30f3\u30dc\u30eb\u3067\u6271\u3046\u969b\u306f\u4ee5\u4e0b\u306e\u8a18\u8ff0\u3067\u3082OK\u3068\u306e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sales = {takayama: 200, webcyou: 300 }<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">200<\/pre>\n<p>\u30e1\u30bd\u30c3\u30c9\u4f8b\u3068\u3057\u3066<strong>\u300csize\u300d\u300ckeys\u300d\u300cvalues\u300d<\/strong>etc&#8230;. \u00a0\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308b\u304b\u3069\u3046\u304b\u306f<strong>\u300chas_key?\u300d<\/strong>\u3067\u5224\u5b9a\u53ef\u80fd\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">p sales.has_key?(:takayama)<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">true<\/pre>\n<p>\u305d\u306e\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u7b49\u306b\u95a2\u3057\u3066\u306f\u3001\u30b3\u30a2\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306e<strong>Hash\u30af\u30e9\u30b9\u3092\u53c2\u7167<\/strong>\u3002<\/p>\n<p>\uff08\u30d0\u30fc\u30b8\u30e7\u30f3\u306f2.2.0\uff09<\/p>\n<p><a href=\"http:\/\/ruby-doc.org\/core-2.2.0\/Hash.html\" target=\"_blank\">http:\/\/ruby-doc.org\/core-2.2.0\/Hash.html<\/a><\/p>\n<h4>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u63db<\/h4>\n<p>\u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6570\u5b57\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\uff08\u6574\u6570\u5024\uff09.to_i<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = \"10\"\r\na.to_i<\/pre>\n<p>\u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6570\u5b57\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\uff08\u5b9f\u6570\u5024\uff09.to_f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = \"10\"\r\na.to_f<\/pre>\n<p>\u6570\u5b57\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b .to_s<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = 10\r\na.to_s<\/pre>\n<p>\u30cf\u30c3\u30b7\u30e5\u3092\u914d\u5217\u306b .to_a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">h = {takayama: 200, webcyou: 300 }\r\np h.to_a<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;&#x5B;:takayama, 200], &#x5B;:webcyou, 300]]<\/pre>\n<p>\u914d\u5217\u3092\u30cf\u30c3\u30b7\u30e5\u306b .to_h<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = &#x5B;&#x5B;:takayama, 200], &#x5B;:webcyou, 300]]\r\np a.to_h<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{:takayama=&gt;200, :webcyou=&gt;300}<\/pre>\n<h4>%\u8a18\u6cd5<\/h4>\n<p>%Q\u3067\u6587\u5b57\u5217\u3068\u3057\u3066\u5909\u63db\u3055\u308c\u308b\u3002\u306a\u3093\u3068\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">s = %Q(hello)\r\np s<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\"hello\"<\/pre>\n<p>%Q()\u306f\u00a0<strong>%Q{}<\/strong> \u3067\u3082<strong>%Q!!<\/strong> \u3067\u3082OK\u3068\u306e\u4e8b\u3002<\/p>\n<p>\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u5909\u63db\u3059\u308b\u5834\u5408\u306f\u5c0f\u6587\u5b57 %q\u3067\u5909\u63db\u304c\u53ef\u80fd\u3002<\/p>\n<p>%Q()\u306f \u7701\u7565\u53ef\u80fd\u3067 <strong>\u300c%()\u300d\u300c%{}\u300d\u300c%!!\u300d<\/strong>\u3068\u8a18\u8ff0\u3067\u3082\u540c\u69d8\u306b\u6271\u3048\u308b\u3002<\/p>\n<p>\u306a\u3093\u3068\u3002<\/p>\n<p>\u307e\u305f\u3001\u6587\u5b57\u5217\u306e\u914d\u5217\u306e\u5834\u5408\u306f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = &#x5B;\"a\", \"b\", \"c\"]<\/pre>\n<p>\u3068\u3044\u3063\u305f\u3082\u306e\u3082\u3001%\u8a18\u6cd5\u3092\u7528\u3044\u3066\u7701\u7565\u304c\u53ef\u80fd\u3002<\/p>\n<p>(\u5c0f\u6587\u5b57\u306ew\u306b\u3059\u308b\u3068\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff09<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = %W(a b c)<\/pre>\n<p>\u306a\u3093\u3068\u3002<\/p>\n<p><strong>\u6761\u4ef6\u5206\u5c90<\/strong><\/p>\n<p>\u6761\u4ef6\u5206\u5c90\u306b\u95a2\u3057\u3066\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3067<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\u6761\u4ef6\u5206\u5c90 if\r\n    \u771f\r\nelse\r\n    \u507d\r\nend<\/pre>\n<p>\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u8a00\u8a9e\u3068\u3055\u307b\u3069\u5909\u308f\u3089\u306a\u304f\u3001\u3042\u3048\u3066\u30dd\u30a4\u30f3\u30c8\u3092\u6319\u3052\u308b\u3068\u306a\u308b\u3068 end\u3067\u7d42\u4e86\u3092\u660e\u793a\u7684\u306b\u3059\u308b\u3068\u3053\u308d\u3068\u3001\u6761\u4ef6\u3092\u8ffd\u52a0\u3059\u308b\u969b\u306e\u300c<strong>else if\u300d\u306fRuby\u3067\u306f\u300celsif\u300d<\/strong>\u3068\u8a18\u8ff0\u3059\u308b\u3068\u3053\u308d\u3067\u3059\u304b\u306d\u3002<\/p>\n<p>\u3068\u3001\u7701\u7565\u3059\u308b\u8a18\u8ff0\u304c\u7279\u6b8a\u306a\u611f\u3058\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">score = 80\r\nif score &gt; 60\r\n\u00a0 puts &quot;OK!&quot;\r\nend<\/pre>\n<p>\u3053\u308c\u304c\u3001\u7701\u7565\u3057\u3066 \u6761\u4ef6\u5206\u5c90\u7b87\u6240\u306f1\u884c\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">score = 80\r\nputs &quot;OK!&quot; if score &gt; 60<\/pre>\n<p>\u306a\u3093\u3068\u3002\u697d\u3067\u3042\u308b\u3002<\/p>\n<h5>\u771f\u507d\u5024<\/h5>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5b58\u5728\u3059\u308b\u304b\u3069\u3046\u304b\u3082\u30b9\u30de\u30fc\u30c8\u306a\u8a18\u8ff0\u3067<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">if x\r\n    puts \"...\"\r\nend<\/pre>\n<p>\u305d\u306e\u4ed6\u3001\u4e09\u9805\u6f14\u7b97\u5b50\u3082\u4ed6\u3068\u540c\u69d8\u306b\u5229\u7528\u3067\u304d\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">a = b &gt; c ? b :c <\/pre>\n<p>\u30c8\u30ea\u30c3\u30ad\u30fc\u3060\u306a\u3068\u611f\u3058\u305f\u306e\u306f\u3001\u300c\u591a\u91cd\u4ee3\u5165\u300d\u3067\u3059\u304b\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">b, c = 10, 20<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u8907\u6570\u4ee3\u5165\u51fa\u6765\u308b\u3068\u306e\u3053\u3068\u3002\u304a\u3049\u3002\u30ef\u30f3\u30c0\u30d5\u30eb\u3002<\/p>\n<h5>case \u5206\u5c90<\/h5>\n<p>case\u6587\u306b\u95a2\u3057\u3066\u306f\u7279\u5225\u306a\u3068\u3053\u308d\u306f\u306a\u304f\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">case \u6bd4\u8f03\u3057\u305f\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\r\n    when \u5024\r\n        \u51e6\u7406\r\n    when \u5024\r\n        \u51e6\u7406\r\n    else \u3069\u308c\u3082\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\r\n        \u51e6\u7406\r\n    end<\/pre>\n<p>\u3068\u3001\u3053\u306e\u3088\u3046\u306a\u5f62\u3067\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>when \u3067\u3053\u306e\u3088\u3046\u306b when &#8220;hoge1&#8221;, &#8220;hoge2&#8221; \u3068\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u8907\u6570\u6307\u5b9a\u3067\u304d\u308b\u306e\u306f\u3053\u308c\u307e\u305f\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<h4>\u7e70\u308a\u8fd4\u3057\u51e6\u7406<\/h4>\n<p>\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3067\u5229\u7528\u3059\u308b<strong>\u300ctimes\u300d<\/strong>\u3053\u308c\u307e\u305f\u7279\u6b8a\u306a\u304b\u3093\u3058\u3067\u3059\u3088\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">3.times do\r\n    puts \"hello\"\r\nend<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">hello&lt;\/p&gt;\r\n&lt;p&gt;hello&lt;\/p&gt;\r\n&lt;p&gt;hello<\/pre>\n<p>\u3042\u3068\u3001\u4f55\u56de\u3081\u306e\u51e6\u7406\u306a\u306e\u304b\u306eindex\u3082\u53d6\u5f97\u3067\u304d\u307e\u3059\u306d\u3002<\/p>\n<p>\u305d\u306e\u969b\u306f\u3001do\u306e\u3042\u3068\u306b |i| \u3067\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">3.times do |i|\r\n    puts \"#{i}: hello\"\r\nend<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">0: hello\r\n1: hello\r\n2: hello<\/pre>\n<p>while\u6587\u306f\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u4f7f\u3048\u307e\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">while i &lt; 3 do<\/pre>\n<p>\u3042\u3068\u3001\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\u51e6\u7406 \u300cbreak\u300d\u306e\u4ed6\u306b\u300cnext\u300d\u3082\u3042\u308b\u3068\u306e\u4e8b\u3002<\/p>\n<p>\u81f3\u308c\u308a\u5c3d\u304f\u305b\u308a\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">if 1 == 0\r\n    next\r\nend<\/pre>\n<p>\u3066\u306a\u611f\u3058\u3067\u6761\u4ef6\u304c\u771f\u306e\u6642\u3001\u51e6\u7406\u304c\u30b9\u30ad\u30c3\u30d7\u3055\u308c\u307e\u3059\u3002<\/p>\n<h4>for\u6587 each\u6587<\/h4>\n<p>for\u6587\u306b\u95a2\u3057\u3066\u306f\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u5229\u7528\u3067\u304d\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">for i in 0..2 do\r\n    puts i\r\nend<\/pre>\n<p>each\u6587\u3067\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u884c\u3046\u5834\u5408\u306f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;\"red\", \"blue\", \"pink\"].each do |color|\r\n    puts color\r\nend<\/pre>\n<p>\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3082\u307e\u305f\u3001\u914d\u5217\u3082\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3046 Ruby\u307d\u3044\u8a18\u8ff0\u3067\u3059\u306d\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u914d\u5217\u3092\u305d\u306e\u307e\u307e\u30cf\u30c3\u30b7\u30e5\u306b\u7f6e\u304d\u63db\u3048\u3066\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u3001<\/p>\n<p>\u305d\u306e\u969b\u3001<strong>key\u3068value\u306f \u300c || \u300d \u5185\u3067\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u53d6\u5f97\u304c\u53ef\u80fd<\/strong>\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{&quot;red&quot;=&gt; 200, &quot;blue&quot;=&gt;100, &quot;pink&quot;=&gt;50}.each do |color, price|\r\n    puts &quot;#{color}: #{price}&quot;\r\nend<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">red: 200\r\nblue: 100\r\npink: 50<\/pre>\n<h4>\u30e1\u30bd\u30c3\u30c9<\/h4>\n<p>\u81ea\u4f5c\u30e1\u30bd\u30c3\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3067\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">def \u95a2\u6570\u540d\r\n    \u51e6\u7406\r\nend<\/pre>\n<p>\u5f15\u6570\u304c\u3042\u308b\u5834\u5408\u306f\u95a2\u6570\u540d\u306e\u5f8c\u306b\uff08\uff09\u3067\u6307\u5b9a\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u6307\u5b9a\u3082\u53ef\u80fd\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">def sayHi(name = \"webcyou\")\r\n    puts \"hello! \" + name\r\nend\r\n\r\nsayHi(\"takayama\")\r\nsayHi()\r\n<\/pre>\n<p><strong>&#8211; result<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">hello! takayama\r\nhello! webcyou<\/pre>\n<p><strong>\u8fd4\u308a\u5024\u3092\u5f97\u308b\u969b\u306ereturn\u306f\u7701\u7565\u304c\u53ef\u80fd<\/strong>\u3068\u306e\u4e8b\u3002<\/p>\n<p>\u306a\u3093\u3068\u3002\u3002\u3002<\/p>\n<p>\u3069\u3053\u307e\u3067\u7701\u7565\u53ef\u80fd\u306a\u306e\u3060\u3002\u3002<\/p>\n<p>\u5f8c\u3001\u95a2\u6570\u5185\u3067\u5b9a\u7fa9\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u81ea\u52d5\u7684\u306b\u30ab\u30d7\u30bb\u30eb\u5316\u3055\u308c\u308b\u3088\u3046\u3067\u3001\u5916\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u306f\u3067\u304d\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<h4>\u30af\u30e9\u30b9<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">class User\r\n    def initialize(name)\r\n        @name = name\r\n    end\r\n\r\n    def sayHi\r\n        puts \"hello, my name is #{@name}\"\r\n    end\r\nend\r\n\r\ntom = User.new(\"tom\")\r\ntom.sayHi()<\/pre>\n<p>\u300c<strong>def initialize\u300d<\/strong>\u306f\u30af\u30e9\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u969b\u306b\u51e6\u7406\u304c\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n<p>@hogege \u3068<strong>\u300c@\u300d\u304c\u4ed8\u4e0e\u3055\u308c\u305f\u5909\u6570\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570<\/strong>\u3068\u306a\u308a\u3001\u30af\u30e9\u30b9\u5185\u306e<strong>\u4ed6\u5b9a\u7fa9\u3057\u305f\u5dfb\u6570\u304b\u3089\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u53ef\u80fd<\/strong>\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<h5>\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u3001\u30af\u30e9\u30b9\u5909\u6570<\/h5>\n<p>\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u969b\u306f\u3001\u300c\u30af\u30e9\u30b9\u540d.\u5b9a\u7fa9\u95a2\u6570\u300d\u3067\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">def User.sayHello <\/pre>\n<p>User\u30af\u30e9\u30b9\u5185\u3067\u4e0a\u8a18\u3092\u5b9a\u7fa9\u3001<strong>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u306a\u304f\u3066\u3082\u547c\u3073\u51fa\u3057\u304c\u53ef\u80fd<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">User.sayHello()<\/pre>\n<p>\u307e\u305f\u3001<strong>\u300c@@\u300d\u3067\u30af\u30e9\u30b9\u5909\u6570\u3082\u5b9a\u7fa9<\/strong>\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u306e\u30af\u30e9\u30b9\u3084\u30b5\u30d6\u30af\u30e9\u30b9\u3001\u305d\u308c\u3089\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u5171\u6709\u3055\u308c\u308b \u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30af\u30e9\u30b9\u304b\u3089<strong>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u305f\u969b\u306b\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7<\/strong>\u3059\u308b\u30af\u30e9\u30b9\u5909\u6570<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">class User\r\n    @@count = 0 #\u30af\u30e9\u30b9\u5909\u6570\r\n    def initialize()\r\n        @@count += 1\r\n    end\r\n\r\n    def User.sayHello #\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\r\n        puts \"hello from User class(#{@@count})\"\r\n    end\r\nend<\/pre>\n<h4>\u7d99\u627f<\/h4>\n<p>Ruby\u306e<strong>\u30af\u30e9\u30b9\u306e\u7d99\u627f\u306f\u4e0d\u7b49\u53f7\u306e\u300c\uff1c\u300d\u3067\u884c\u3048\u308b<\/strong>\u3068\u306e\u3053\u3068\u3002\u3053\u308c\u307e\u305f\u306a\u3093\u3068\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">class SuperUser &lt; User<\/pre>\n<p>\u3066\u306a\u611f\u3058\u3067\u3002<\/p>\n<p>\u3053\u308c\u307e\u305f\u3001\u697d\u306a\u611f\u3058\u3067\u3059\u306d\u3002\u3075\u3080\u3002<\/p>\n<h4>get\u30a2\u30af\u30bb\u30b5\u3001set\u30a2\u30af\u30bb\u30b5\uff08getter,setter\uff09<\/h4>\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3092\u5916\u90e8\u304b\u3089\u53c2\u7167\u3059\u308b\u306b\u7528\u3044\u308bgetter\u306fRuby\u3067\u306f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">def name\r\n    return @name\r\nend<\/pre>\n<p>setter\u306f\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3044\u3051\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">def setName(newName)\r\n    @name = newName\r\nend<\/pre>\n<p>\u66f4\u306b\u300cattr_accessor\u300d\u3092\u7528\u3044\u308b\u3068\u5bb9\u6613\u306b\u6271\u3048\u308b\u3068\u306e\u3053\u3068\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">attr_accessor :name<\/pre>\n<p>setter\u3082 hoge.name = &#8216;hoge&#8217; \u3067\u5b9f\u884c\u53ef\u80fd\u3002<\/p>\n<p>attr_accessor\u306fgetter,\u3001setter\u306e\u4e21\u65b9\u3067\u3059\u304c\u3001\u305d\u308c\u305e\u308c\u306e\u6307\u5b9a\u3082\u53ef\u80fd\u3002<\/p>\n<p><strong>getter\u306e\u307f<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">attr_reader :name<\/pre>\n<p><strong>setter\u306e\u307f<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">attr_writer :name<\/pre>\n<p>\u30af\u30e9\u30b9\u304c\u5927\u304d\u304f\u306a\u308b\u3068\u3001getter\u3001setter\u3060\u3051\u3067\u884c\u6570\u3082\u5897\u3048\u3066\u3057\u307e\u3044\u304c\u3061\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u8a18\u8ff0\u304c\u6e1b\u308a\u3001\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u7d42\u308f\u308a\u306b<\/h4>\n<p>\u3068\u3001\u6539\u3081\u3066\u66f8\u3044\u3066\u307f\u3066\u3001<strong>Ruby\u306f\u67d4\u8edf\u6027\u304c\u3042\u3063\u3066\u66f8\u3044\u3066\u3066\u697d\u3057\u3044\u8a00\u8a9e<\/strong>\u3060\u306a\u3068\u6539\u3081\u3066\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<p><strong>Ruby on Rails<\/strong>\u00a0\u3082\u304d\u3063\u3068\u5bb9\u6613\u306b\u6271\u3048\u3066\u697d\u3057\u3044\u3093\u3060\u308d\u3046\u306a\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u3089\u89e6\u3063\u3066\u898b\u3088\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u5f8c\u3001<strong>\u4f55\u304b\u65b0\u3057\u304f\u8a00\u8a9e\u3092\u899a\u3048\u305f\u308a\u3059\u308b\u969b\u306f\u4e00\u5ea6\u300c\u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u300d<\/strong>\u3092\u78ba\u8a8d\u3059\u308b\u3068\u826f\u3044\u3067\u3059\u306d\uff01\u6539\u3081\u3066\u4fbf\u5229\u3055\u3092\u611f\u3058\u307e\u3057\u305fw<\/p>\n<p>\u4e0b\u624b\u306b\u66f8\u7c4d\u7b49\u3092\u8cfc\u5165\u3059\u308b\u3088\u308a\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u306d\uff08\u8fbc\u307f\u5165\u3063\u305f\u3053\u3068\u3092\u884c\u3046\u969b\u306f\u8a71\u304c\u5225\u3067\u3059\u3002\uff09<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f \u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u53c2\u7167\u306b Ruby\u306f\u3058\u3081\u308b\u969b\u306e\u307e\u3068\u3081\u3092\u6587\u66f8\u306b\u307e\u3068\u3081\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305fmm<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/39cc0b4469b3230707addc5f896110da.png\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2015-04-09 17.05.54\" width=\"512\" height=\"204\" \/><\/a><\/p>\n<p><strong>\u516c\u5f0f\u30b5\u30a4\u30c8<\/strong><\/p>\n<p><a href=\"http:\/\/dotinstall.com\/\" target=\"_blank\">http:\/\/dotinstall.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 Ruby on Rails\u3067\u6700\u8fd1\u3082\u3063\u3071\u3089\u4f55\u304b\u3068\u8a71\u984c\u306eRuby\u754c\u9688\u3002 \u516c\u5f0f\u30b5\u30a4\u30c8 https:\/\/www.ruby-lang.org\/ja\/ \u8a00\u308f\u305a\u3068\u77e5\u308c\u305f\u3001\u300c\u307e\u3064\u3082\u3068\u3086\u304d\u3072\u308d\uff08\u901a\u79f0 Matz\uff09\u3055\u3093\u300d\u304c\u958b\u767a\u3057\u305f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[155],"tags":[183,44,45,178,78,114,118],"class_list":{"0":"post-5734","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-ruby","7":"tag-ruby","8":"tag-web","10":"tag-178","11":"tag-78","12":"tag-114","13":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5734"}],"version-history":[{"count":10,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5734\/revisions"}],"predecessor-version":[{"id":5746,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/5734\/revisions\/5746"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}