Calling function within class.
Ali Çehreli
acehreli at yahoo.com
Wed Nov 18 21:23:44 UTC 2020
On 11/18/20 11:25 AM, Vino wrote:
> why is this
> so complicated in D where as in PHP it is simple like below
>
> PHP Code:
> class PHPclass {
> function test1 ($st) { return $st; }
> function test2 () { return $this->test1("Test"); }
> }
>
> $obj = new PHPclass();
> print_r($obj->test2());
It is so similar in D that one can say they are the same:
class PHPclass {
auto test1(T)(T st) { return st; }
auto test2() { return this.test1("Test"); }
}
import std.stdio;
void main() {
auto obj = new PHPclass();
writeln(obj.test2());
}
Ali
More information about the Digitalmars-d-learn
mailing list