Bane Wrote:

> Nrgyzer Wrote:
> 
> > Hello everyone,
> > 
> > how can I add a char to a char-array by using a other class?
> > 
> > For example:
> > 
> > class A {
> > 
> >    private char[] text;
> > 
> >    this() {
> >    ...
> >       text ~= "a";
> >       new B(text);
> >       writefln(text);
> >    ...
> >    }
> > 
> > }
> > 
> > class B {
> > 
> >    this(char[] text) {
> >    ...
> >       text ~= "b";
> >    ...
> >    }
> > 
> > }
> > 
> > This should write "ab" in the command line, but only "a" is shown.
> > 
> > ... Thanks for help :).
> 
> 
> No, it shouldn't. What goes in B, stays in B. But if you add magic 'ref' or 
> 'inout' keyword it might work:
> 
>  class B {
> 
>     this(inout char[] text) {
>     ...
>        text ~= "b";
>     ...
>     }
>  
>  }
> 

Thanks, that's exactly what I needed :)

Reply via email to