Consider this code:
Class Entity
Field name := "entity"
Method New()
Error( "Please use New( name:String )" )
End
Method New( name:String )
Self.name = name
End
End
Class EntityA Extends Entity
End
Function Main()
Local a := New EntityA
Print a.name
End
If you run this, you get the error "Please use New( name:String )", which is the behavior I expect, since EntityA is inheriting New() from Entity. but if you replace:
Local a := New EntityA
With:
Local a := New EntityA( "Entity Name" )
You ALSO get an error, this time from Monkey saying "Unable to find overload for new(String).". Why? Shouldn't the method New( name:String ) be inherited as well, since New() was inherited?
I find it a little annoying, because I want all my extended entity classes to use the same New( name:String ) method, unless I explicitly define a new one. As it is, I have to redefine it for every new extended class simply so it can call Super.New( name:String ) ...
|