type_annotations/function_annotations.rb
tests/_examples/type_annotations/function_annotations.rb in the metorex repository.
def greet(name, age) # str, int -> str
"Hello, " + name
end
def add(a, b) # int, int -> int
a + b
end
def multiply(x, y) # float, float -> float
x * y
end
message = greet("Bob", 25)
puts message
sum_result = add(10, 20)
puts "10 + 20 = #{sum_result}"
product = multiply(3.5, 2.0)
puts "3.5 * 2.0 = #{product}"