Ruby的case语句
case语句使用的是===判断方式,可以进行更加广义的相等判断;
可以进行类型的判断,可以进行正则表达式的判断;
- array = ["a",1,nil]
- array.each { |ai|
- case ai
- when String
- puts "#{ai} is string"
- when Numeric
- puts "#{ai} is number"
- when nil
- puts "#{ai} is else"
- end
- }
以上就是Ruby的case语句的详细内容,更多关于Ruby的case语句的资料请关注九品源码其它相关文章!