What are the scenarios we can use ?
What does this means a class implement another class or an interface
implement a class?
I think in most cases, we should extends a class instead of implement
a class.
Dart is single-inheritance and multi-implement. But if class seen as
interface, we can implement
multi class:
class A
class B
class C implements A, B
Hi,
This feature isn't implemented yet, but the idea is that you can avoid having to define both an interface and a class. If you use a class in an implements clause, you will be implementing the interface implicitly defined bu that class, but not inheriting from it. So you will not get the field layout, you won't inherit the methods etc. You are just declaring that your new class will conform to the interface of that class.
class Point {var x, y;}
class PolarPoint implements Point {var rho, theta;get x ...get y ...}
new PolarPoint() is Point; // true
PolarPoint does not have extra storage for x and y variables, but it emulates the protocol of a Point and is recognized as such by the system.
Very cool idea.
In that case, is there still a need for a keyword interface.
cheers,
Rémi
Hi Sean,
Can you provide an example of how static members would lead to confusion with the implicit interface of a class?
On Wed, Nov 23, 2011 at 3:13 PM, Peter Ahé <a...@google.com> wrote:
Hi Sean,
Can you provide an example of how static members would lead to confusion with the implicit interface of a class?Say you have a class which only has static members. A better way to do this would be to just make everything top-level in the library, and not even have a class, but since dart supports static members, and since it's the java way, it will be done:class Utils {static String x = "x";static final int y = 1;static int foo( ) {/*...*/}static String bar(int x) {/*...*/}}