Re: Modify char in string

2014-05-19 Thread Tim via Digitalmars-d-learn
On Sunday, 18 May 2014 at 19:09:52 UTC, Chris Cain wrote: On Sunday, 18 May 2014 at 18:55:59 UTC, Tim wrote: Hi everyone, is there any chance to modify a char in a string like: As you've seen, you cannot modify immutables (string is an immutable(char)[]). If you actually do want the string

Re: Modify char in string

2014-05-19 Thread Ali Çehreli via Digitalmars-d-learn
On 05/19/2014 10:07 AM, Tim wrote: I already tried: void main() { char[] sMyText = Replace the last char_; sMyText[$ - 1] = '.'; } but I always getting Error: cannot implicitly convert expression (Replace the last char_) of type string to char[].

Modify char in string

2014-05-18 Thread Tim via Digitalmars-d-learn
Hi everyone, is there any chance to modify a char in a string like: void main() { string sMyText = Replace the last char_; sMyText[$ - 1] = '.'; } But when I execute the code above I'm always getting cannot modify immutable expression at sMyText[__dollar -1LU]. I though D supported

Re: Modify char in string

2014-05-18 Thread bearophile via Digitalmars-d-learn
Tim: is there any chance to modify a char in a string like: void main() { string sMyText = Replace the last char_; sMyText[$ - 1] = '.'; } But when I execute the code above I'm always getting cannot modify immutable expression at sMyText[__dollar -1LU]. I though D supported such

Re: Modify char in string

2014-05-18 Thread Chris Cain via Digitalmars-d-learn
On Sunday, 18 May 2014 at 18:55:59 UTC, Tim wrote: Hi everyone, is there any chance to modify a char in a string like: As you've seen, you cannot modify immutables (string is an immutable(char)[]). If you actually do want the string to be modifiable, you should define it as char[] instead.