On Tuesday, 15 November 2022 at 14:26:22 UTC, Imperatorn wrote:
Side-note, you don't override interface members, you implement
them.
My knowledge of D is still modest, most likely, I just didn't
know that override with interfaces can not be used. Thanks for
the hint!
On Tuesday, 15 November 2022 at 14:09:01 UTC, bauss wrote:
If you cast to Object and use classinfo.name then you get the
expected result of B.
Thanks! 😌
On Tuesday, 15 November 2022 at 12:25:22 UTC, Hipreme wrote:
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
As shown you can use Object for this.
Side-note, you don't override interface members, you implement
them.
```d
interface A
{
string
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new
On Tuesday, 15 November 2022 at 12:25:22 UTC, Hipreme wrote:
You can do it as `val.classinfo.name`
Yes, I have already done so, but the result is the same, actually
:)
```d
app.A: It's ok!
app.A: It's ok!
app.A: It's ok!
```
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new B();
fill(a, b);
foreach (val ; a) {
writeln(typeof(va