| |
 | Posted by Zoda in reply to monkyyy | Permalink Reply |
|
Zoda 
Posted in reply to monkyyy
| On Tuesday, 17 June 2025 at 19:29:16 UTC, monkyyy wrote:
> On Tuesday, 17 June 2025 at 19:15:33 UTC, Zoda wrote:
> Hi, I need my struct to convertable to 'wchar' my struct looks like this
struct ColoredChar {
int[3] rgb;
wchar ch;
}
// Existing functions looks like this
void doSomething(wchar ch) {
...
}
i don't want my existing functions to break so i need my struct to be convertable to a 'wchar', how can achieve this?
Thanks, Zoda.
import std;
struct ColoredChar {
int[3] rgb;
wchar ch(){
return 'a';
}
alias ch this;
}
// Existing functions looks like this
void doSomething(wchar ch) {
ch.writeln;
}
unittest{
ColoredChar().doSomething;
}
Thanks, i works but can i want to do something like ColoredChar([255,0,0], '█')
can its possible?
Thanks again, Zoda.
|