Wrong assumption about overloading?

Monkey Forums/Monkey Beginners/Wrong assumption about overloading?

Sammy(Posted 2014) [#1]
Hi,

I am probably doing this under the wrong assumption. That is, that you can overload a method by return value?

See my snippet here..

Method GetByName:Float(Name:String)
	Return Self.myFloats.FindName(Name)
End
	
Method GetByName:Int(Name:String) '<-- Duplicate declaration Method error! :(
	Return Self.myInts.FindName(Name)
End


So if a# = GetByName("blah") then it would call the 1st method
Also, if b% = GetByName("bleh") then it would call the second method?


Goodlookinguy(Posted 2014) [#2]
No, you can not overload by return value, only by arguments.


AdamRedwoods(Posted 2014) [#3]
no, but you can use generics.


Sammy(Posted 2014) [#4]
Thanks for clearing that up Goodlookinguy. And that's a great suggestion too Adam, thank you, I'll give that a go instead.