Sealed classes - would you want them in D? (v2)
KingJoffrey
KingJoffrey at KingJoffrey.com
Sat May 19 09:10:32 UTC 2018
On Saturday, 19 May 2018 at 08:32:28 UTC, Uknown wrote:
>
> I ported your example to Java. Surprisingly, it compiled and
> executed just fine:
All I see, is a class, with static members. How else would it
work?
This is the equivalent of my D example, in Java:
( it won't even compile. phew! )
--------------
public class test
{
public static void main(String[] args)
{
Dog dog = new Dog();
dog.noiseType = "meow"; // no way jose
System.out.println(dog.makeNoise()); // phew! cause dogs
don't meow.
}
}
class Dog
{
private String noiseType = "woof";
public String makeNoise()
{
return this.noiseType;
}
}
--------------------
More information about the Digitalmars-d
mailing list