E
Eugen Ciur
Hi all,
how can I write case statement to check of specific type the variable has?
Something like:
case var
when :Fixnum
puts "#{var} is Fixnum"
when :String
puts "#{var} is String"
end
I tried this also
case var.class
when 'Fixnum'
puts "#{var} is Fixnum"
when 'String'
puts "#{var} is String"
end
but ruby refuses to understand me
What is the best way to write conditional that depends of variable type?
Thank you!
how can I write case statement to check of specific type the variable has?
Something like:
case var
when :Fixnum
puts "#{var} is Fixnum"
when :String
puts "#{var} is String"
end
I tried this also
case var.class
when 'Fixnum'
puts "#{var} is Fixnum"
when 'String'
puts "#{var} is String"
end
but ruby refuses to understand me
What is the best way to write conditional that depends of variable type?
Thank you!