Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 07, 2003 string documentation wrong? | ||||
---|---|---|---|---|
| ||||
The docs say: Strings can be copied, compared, concatenated, and appended: char[] str; char[] str1 = "abc"; str1 = str2; if (str1 < str3) ... func(str3 + str4); str4 += str1; with the obvious semantics. It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? Cheers, Sarat |
October 07, 2003 Re: string documentation wrong? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sarat Venugopal | as you say, suported with ~.. so use ~instead of + func(string3 ~ string4); string3 ~= string4; and similar.. not sure about the <, i have to read that up again, haven't used it yet.. In article <blv327$15gn$1@digitaldaemon.com>, Sarat Venugopal says... > >The docs say: > >Strings can be copied, compared, concatenated, and appended: char[] str; > >char[] str1 = "abc"; > >str1 = str2; > >if (str1 < str3) ... > >func(str3 + str4); > >str4 += str1; > >with the obvious semantics. > >It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? > >Cheers, > >Sarat > > |
October 08, 2003 Re: string documentation wrong? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sarat Venugopal | Sarat Venugopal wrote:
> The docs say:
>
> Strings can be copied, compared, concatenated, and appended:
> char[] str;
>
> char[] str1 = "abc";
>
> str1 = str2;
>
> if (str1 < str3) ...
>
> func(str3 + str4);
>
> str4 += str1;
>
> with the obvious semantics.
> ...
Two comments:
1) do be aware that D is still a work in progress. I'm never certain before I try just which language features have actually been implemented.
2) shouldn't that be str4 ~= str1 rather than str4 += str1 ?
2a) if you're missing a feature, you might be able to implement it yourself in a subclass via redefining the operation. (I admit I haven't tried this with the "array of chars" type. But for some other's it's worked well.... I say without having gotten the application to the point where I can do unit testing.)
|
October 08, 2003 Re: string documentation wrong? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sarat Venugopal Attachments: | Sarat Venugopal wrote:
> The docs say:
>
> Strings can be copied, compared, concatenated, and appended: char[] str;
>
> char[] str1 = "abc";
>
> str1 = str2;
>
> if (str1 < str3) ...
>
> func(str3 + str4);
>
> str4 += str1;
>
> with the obvious semantics.
>
> It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here?
>
> Cheers,
>
> Sarat
Comparisons (<, >, and ==) work for me. Use the ~ for appending and concatenation. I've attached an example that works on my system. If my example doesn't help, it might be useful for you to post a complete example (whether it compiles or not).
I'm running WindowsXP. I don't know if my example works on the Linux version (if it doesn't that would probably indicate a compiler bug).
Hope this helps.
Justin
|
October 08, 2003 Re: string documentation wrong? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sarat Venugopal | "Sarat Venugopal" <sarat_ng@n0spam.huelix.com> wrote in message news:blv327$15gn$1@digitaldaemon.com... > The docs say: > > Strings can be copied, compared, concatenated, and appended: char[] str; > > char[] str1 = "abc"; > > str1 = str2; > > if (str1 < str3) ... > > func(str3 + str4); > > str4 += str1; > > with the obvious semantics. > > It errors out with "Array operations not implemented". I see that concatenantion is supported by ~. Am I missing something here? The documentation is wrong; '~' is the concatenate operator for strings, not '+'. Similarly, use '~=' for append, not '+='. I've corrected the documentation. |
Copyright © 1999-2021 by the D Language Foundation