On 2015-07-23 00:22, nurfz wrote:
I think you got overly complicated answers.
I guess I'm confused as to why the D code isn't acting similar to the
Python code in the sense that you would expect this to reference the
speed property of the current instance and not statically reference
the
On Wednesday, 22 July 2015 at 22:52:22 UTC, John Colvin wrote:
On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote:
[...]
Fields of classes are not in any way polymorphic in D (this is
the same as C++ and I think java too). Base class members can
be accessed like so:
class Vehicle {
On Wednesday, July 22, 2015 23:19:35 nurfz via Digitalmars-d-learn wrote:
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
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?
On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote:
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);
}
}
On Wednesday, July 22, 2015 22:22:00 nurfz via Digitalmars-d-learn wrote:
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() {