Rubyã³ã¼ãã£ã³ã°ããããï¼åãã¦ã®æ¹ããï¼è¤éãªifè«çã®è¨è¿°ï¼
ããæ¬å°éã®äºæ¸¬ãããã»ããã°ã©ã ã¯Rubyã§æ¸ããã¦ãã¾ããã以åããåãã¦ã®æ¹ããã«ã³ã¼ãã£ã³ã°ãã¯ã®ãããªã¢ããã¾ã¨ãã¦ãããã°ãã¨èãã¦ãã¾ããããããã§æãä»ãã¾ã¾ã«ã¾ã¨ãã¦ã¿ãããã¨èãã¦ããã¾ãã
ã¾ãæåã¯ãè¤éãªè«çã®ifæãæ¸ãéã®ãã¯ããã¯ã§ãããï¼çãã¾ã¨ãã¾ãï¼
Â
ifæã§ããããä¸è¬çã«ã¯ï¼
if condition1ãã# æ¡ä»¶ï¼ãæºããã°
    data transfer operation1ã# ãã¼ã¿å¦çï¼ãå®è¡
elsif condition2ãã# æ¡ä»¶ï¼ãæºããã°
   data transfer operation2ã# ãã¼ã¿å¦çï¼ãå®è¡
...ã# ããã¤ã elsif ã§ãã¹ãããã¦
elseãã# ä¸è¨æ¡ä»¶ç¾¤ãæºãããªãå ¥åæ¡ä»¶ãå¨ãã°
  abort(message)ãã# ã¢ãã¼ã
endãã# ã¨ããäºã«ãªããã¨æãã¾ãã
Â
ãããã®ããã«æåãããããã«æ¸ããã°è¯ãã®ã§ãããå ¥åæ¡ä»¶ãåãããªããã¾ã ãã¹ã¦æ±ºã¾ã£ã¦ããªããä»æ§ãä¸æ確ãã¨ãã£ãäºã¯ããããã¨æãã¾ãã
ãã®ãããªå ´åã«ã¯ãifæã®éä¸ã§è±åºããããã¨ããäºã«ãªãã¾ããããã®ããæ¹ã§ãã
ä¸è¨ãä¾ã«åãã°ï¼
loop doãã# ç¡éloop 宣è¨ãã ããsingle loopã«ãã¦ãã¾ã
if condition1
   data transfer operation1  Â
break endãã# condition1 ã®çµäºãloopããè±åº
if condition2
   data transfer operation2 Â
break endãã# condition2 ã®çµäºãloopããè±åº
...
abort(message)ãã# ã¢ãã¼ã
break endã# ãããã® loop doã®è±åºï¼çµäºï¼å®£è¨
abortå¦çã®æã§æ³å®ãã¦ããªãã£ãå ¥åæ¡ä»¶ãåããã¾ããããæ°ãã« if break end ãããã¯ãå ¥ããã¹ãç®æã«èªç±ã«è¿½å ãã¦ããã¾ããããããã¦ããã°ã©ã ã«ãããã°ãããªããããã°ã©ã ãå®æããã¦ããã¾ãã
Â
ããå®æããæã«ããã®ãããã¯ãä½ç¾ä¸åãã³ã¼ã«ããããããªå ´æã«ããã°ãelsifåã«æ¸ãç´ãã¾ãï¼ã¹ãã¼ãã¯elsifã®æ¹ãæç¶æ©ãã®ã§ãï¼ããããã§ãªããã°ãã®ã¾ã¾ã§ãã
Â
以ä¸ã§ãã
Â
Â
Â
Â