if conditional [then] code ... [elseif conditional [then] code...]... [else code...] end
x = 1 if x > 2 puts "x is greater than 2" elsif x <2 and x != 0 puts "x is 1" else puts "I can't guess the number" end
$val = 2 print "val is 2\n" if $val == 2
File.open("my.pl").each do | line | next if line.index('#') puts line end
unless conditional [then] code [else code ] end
$var = 1 print "1 -- Value is set\n" if $var print "2 -- Value is set\n" unless $var $var = false print "3 -- Value is set\n" unless $var
case expression [when expression [, expression ...] [then] code ]... [else code ] end
$age = 5 case $age when 0 .. 2 puts "baby" when 3 .. 6 puts "little child" when 7 .. 12 puts "child" when 13 .. 18 puts "youth" else puts "adult" end
little child
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
if
문법
일반적인 예제
ruby스러운 예제
unless
문법
case
문법
예제
Recent Posts
Archive Posts
Tags