try this code
exapmle 1
case nameexample 4
when "banusha"
#some_code
when "kamal"
#some_code
else
#...
end
example 2
case number
when 1
puts "number is equal to 1"
when 2..9
puts "number is between 2 and 9"
when 10
puts "number is equal to 10"
end
example 3
case number
when 1 then puts "number is equal to 1"
when 2..9 then puts "number is between 2 and 9"
when 10 then puts "number is equal to 10"
end
case number
when 1 ; puts "number is equal to 1"
when 2..9 ; puts "number is between 2 and 9"
when 10 ; puts "number is equal to 10"
end
No comments:
Post a Comment