You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caveat: I have mainly written dart code during the last 12 months.
I think it would be great if a class would implicitly define an interface that you could implement (like in dart). The implicit interface would only contain the public instance members of the class and of any interfaces it implements.
This would help in cases where you don't have control over a class, it exists in some third party library, and they haven’t exposed an explicit interface.
Example:
classPerson{// Not in the interface, since this is privateprivatename;// Not in the interface, since this is a constructor.constructor(name : string){this.name=name;}// In the interface.greet(who : string) : string{return`Hello, ${who}. I am ${this.name}.`;}}// An implementation of the Person interface.classImposterimplementsPerson{greet(who : string) : string{return`Hello, ${who}. Do you know who I am?`;}}
The text was updated successfully, but these errors were encountered:
if a class would implicitly define an interface that you could implement (like in dart). The implicit interface would only contain the public instance members of the class and of any interfaces it implements.
The problem is just that if there are non-public members they are not dropped but are also considered part of the implicit interface of the class. The issue Mohamed mentions covers lifting this restriction somehow.
Caveat: I have mainly written dart code during the last 12 months.
I think it would be great if a class would implicitly define an interface that you could implement (like in dart). The implicit interface would only contain the public instance members of the class and of any interfaces it implements.
This would help in cases where you don't have control over a class, it exists in some third party library, and they haven’t exposed an explicit interface.
Example:
The text was updated successfully, but these errors were encountered: