if conditional [then] code... [elsif conditional [then] code...]... [else code...] end
#!/usr/bin/ruby 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 x is 1
#!/usr/bin/ruby $debug=1 print "debug\n" if $debug
debug
unless conditional [then] code [else code ] end
#!/usr/bin/ruby x=1 unless x>2 puts "x is less than 2" else puts "x is greater than 2" end
x is less than 2
#!/usr/bin/ruby $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
1 -- Value is set 3 -- Value is set
case expression [when expression [, expression ...] [then] code ]... [else code ] end
case expr0 when expr1, expr2 stmt1 when expr3, expr4 stmt2 else stmt3 end
_tmp = expr0 if expr1 === _tmp || expr2 === _tmp stmt1 elsif expr3 === _tmp || expr4 === _tmp stmt2 else stmt3 end
#!/usr/bin/ruby $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
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有