Getting this to work similar to self in Python

2015-07-22 Thread nurfz via Digitalmars-d-learn
How could I get this D code to work similar to this Python code? So, here is the D code: import std.stdio; class Vehicle { int speed; void printSpeed() { writeln(this.speed); } } class Airplane: Vehicle { int speed = 100; }

Re: Getting this to work similar to self in Python

2015-07-22 Thread nurfz via Digitalmars-d-learn
Hmm, is there a specific reason aside from the encapsulation violation? It seems needlessly complicated. If you have someone/something that has direct access to your source code, isn't a getter/setter the least of your concerns? Does the @property decorator incur a large runtime cost?