Moving from Java to a different language (29)

19 Name: #!/usr/bin/anonymous : 2006-08-07 17:07 ID:001QwN46

>>17
Sure, but their type is char[]. Which is silly, because there are no immutable arrays in D. Meaning that the following would pass the compiler but produce a segfault or astonishing behaviour depending on whether text segments are read-only on the target platform:

char[] foo(int x, char c) {
char[] poit = "hurble burble";
if(x < poit.length) poit[x] = c;
return poit;
}

I.e. the string literal would be modified through the array access. Which isn't so good.

This thread has been closed. You cannot post in this thread any longer.