Chapter 7: Types and Method Overloading
def add(x, y)
x + y
end
add 3, 5 # 8add 3, "Serdar"types.cr:2:in `+': String can't be coerced into Fixnum (TypeError)
from types.cr:2:in `add'
from types.cr:5:in `<main>'Error in ./types.cr:5: instantiating 'add(Int32, String)'
add 3, "Serdar"
^~~
in ./types.cr:2: no overload matches 'Int32#+' with types String
Overloads are:
- Int32#+(other : Int8)
- Int32#+(other : Int16)
- Int32#+(other : Int32)
- Int32#+(other : Int64)
- Int32#+(other : UInt8)
- Int32#+(other : UInt16)
- Int32#+(other : UInt32)
- Int32#+(other : UInt64)
- Int32#+(other : Float32)
- Int32#+(other : Float64)
- Int32#+()
x + y
^Method Overloading
Last updated