How to get the variable type in Ruby

1 Answer

0 votes
a = 12
b = 8.0
c = 3.14
d = 99743845235925667.8367
e = "837"
f = "Ruby"
g = true
h = false 

puts "#{a.class}\n#{b.class}\n#{c.class}\n#{d.class}\n"
puts "#{e.class}\n#{f.class}\n#{g.class}\n#{h.class}"
 
 
 
# run:
#
# Integer
# Float
# Float
# Float
# String
# String
# TrueClass
# FalseClass
#

 



answered Dec 20, 2020 by avibootz
edited Dec 21, 2020 by avibootz

Related questions

...