D - concatenating char's with char arrays
- Charles Sanders (5/5) Oct 22 2003 Will this ever be possible ?
- Helmut Leitner (14/21) Oct 22 2003 I think all primitives should at least have a toString property.
- Sean L. Palmer (7/25) Oct 23 2003 It seems like converting a basic type like char or int to a slice char[]...
- Vathix (7/28) Oct 23 2003 allow
-
Hauke Duden
(4/10)
Oct 23 2003
- Nicolas Repiquet (11/15) Oct 23 2003 char [] str = "hell";
Will this ever be possible ? char [] str = 'A' ~ " string"; ( im actually running through a string in a for loop , and it doesnt allow casting from char to char [] ) C
Oct 22 2003
Charles Sanders wrote:Will this ever be possible ? char [] str = 'A' ~ " string"; ( im actually running through a string in a for loop , and it doesnt allow casting from char to char [] )I think all primitives should at least have a toString property. For the Moment you could use a canonical function alias char [] String; String CharRetString(char c) { String s="?"; s[0]=c; return s; } String s= CharRetString('A') ~ "abc"; -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 22 2003
It seems like converting a basic type like char or int to a slice char[] or int[] would not only be possible, but cheap as well. It's a one-dimensional, single element array! ;) Sean "Helmut Leitner" <helmut.leitner chello.at> wrote in message news:3F976AD2.9F703033 chello.at...Charles Sanders wrote:allowWill this ever be possible ? char [] str = 'A' ~ " string"; ( im actually running through a string in a for loop , and it doesntcasting from char to char [] )I think all primitives should at least have a toString property. For the Moment you could use a canonical function alias char [] String; String CharRetString(char c) { String s="?"; s[0]=c; return s; } String s= CharRetString('A') ~ "abc";
Oct 23 2003
"Helmut Leitner" <helmut.leitner chello.at> wrote in message news:3F976AD2.9F703033 chello.at...Charles Sanders wrote:allowWill this ever be possible ? char [] str = 'A' ~ " string"; ( im actually running through a string in a for loop , and it doesntThat code looks bad. Remember we're not supposed to write over string literals; and why the String? Here's what I do: char ch = 'A'; char[] s = (&ch)[0 .. 1] ~ "abc";casting from char to char [] )I think all primitives should at least have a toString property. For the Moment you could use a canonical function alias char [] String; String CharRetString(char c) { String s="?"; s[0]=c; return s; } String s= CharRetString('A') ~ "abc"; -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 23 2003
Vathix wrote:<snip>alias char [] String;<snip>String s="?"; s[0]=c;That code looks bad. Remember we're not supposed to write over string literals;Have I ever mentioned that I think D needs a true const type modifier? ;)
Oct 23 2003
"Charles Sanders" <sanders-consulting comcast.net> a écrit dans le message news: bn7b4e$1t8o$1 digitaldaemon.com...Will this ever be possible ? char [] str = 'A' ~ " string"; ( im actually running through a string in a for loop , and it doesnt allow casting from char to char [] )char [] str = "hell"; str ~= 'o'; this works. char[] str = "hell"; str = str ~ 'o'; this dont. I ask walter for this, and i was answered that it is a bug, and it'll be fixed soon. -- Nicolas Repiquet
Oct 23 2003