=begin 条件判断语句包括if语句,unless语句,case语句,=end#if 语句=beginif 条件 then 处理1elsif 条件2 then 处理2else 处理3end=enda = 10b = 20if a > b puts "a bigger than b"elsif a < b puts "a smaller than b"else puts "a is equal to b"endputs "a bigger than b" if a > b#unless 语句,与if语句相反,条件判断为假的时执行处理=beginunless 条件 处理1else 处理2end=enda = 10b = 20unless a > b puts "a smaller/same as than b"end#case 语句,适用于比较的对象只有一个的时候,根据这个对象的值不同,执行不同的处理;when可以一次指定多个值=begincase 比较对象when 值1 then 处理1when 值2 then 处理2when 值3 then 处理3else 处理4end=endtags = ["A", "IMG", "PRE"]tags.each do |word| case word when "P", "A", "I", "B", "BLOCKQUOTE" puts "#{word} has child." when "IMG", "BR" puts "#{word} has child." else puts "#{word} cannoot be used" endendarray = ["a", 1, nil]array.each do |word| case word when String puts "the word is a String" when Numeric puts "the word is a Numeric" else puts "other words are Something" endendtext.each_line do |line| case line when /^From:/i puts "find a sender" when /^To:/i puts "find a receiver" when /^$/ puts "resolution are finnished" exit else break endend