# More type stuff b = 57.5 c = 82.1 # Get all living objects of a type puts "All Numeric objects in the system:" ObjectSpace.each_object(Numeric) { | it | puts it } # 'Reflect' objects puts "\nMethods on range:" range = 5..8 methods = range.methods puts methods[0..4] # Check specific methods / operators puts "\nHas 'min' method? #{range.methods.member?('min')}" puts "Has 'minulation' method? #{range.respond_to?('minulation')}" puts "Has equals overload? #{range.respond_to?('==')}" # Get instance id, class and check inheritance # Notice the difference between is_a? and kind_of? num = 88 puts "\nId is #{num.object_id}" puts "Class is #{num.class}" puts "Is a kind of Fixnum? #{num.kind_of?(Fixnum)}" puts "Is a kind of Numeric? #{num.kind_of? Numeric}" puts "Is an instance of Fixnum? #{num.instance_of?(Fixnum)}" puts "Is an instance of Numeric? #{num.instance_of? Numeric}"