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
But to address your request, there has been discussion at #1612 of specifying types by listing the members you want ("structural typing" or "duck typing", similar to what Python uses). A common example is requesting an object with .length. The syntax hasn't been decided on yet -- or even if this should be allowed -- but it could look something like this:
abstractclassHasLength {
intget length;
}
/// Accepts any object with a `.length` property, even if they don't extend [HasLength].////// That means [String], [Map], [List], [Set], etc. all work.voidprintLength(HasLength obj) =>print(obj.length);
// alternatively: voidprintLength(dynamic<HasLength> obj) =>print(obj.length);
such as C# code:
it's very useful when we want return a value of T, such as:
The text was updated successfully, but these errors were encountered: