Ruby - Variables and Data Types
How does Ruby's dynamic typing help when writing a method that accepts different types of inputs?
Consider this method:
Consider this method:
def describe(value)
if value.is_a?(String)
"String: #{value}"
elsif value.is_a?(Integer)
"Integer: #{value}"
else
"Other type"
end
end
puts describe(10)
puts describe("hello")
puts describe(3.14)