Actually, string.strip() (which uses g_strstrip) returns a new string.

However, you're right, string is not immutable.  This works:

void main() {
    string a = "abc";
    stdout.printf("%s\n", a);

    a.data[0] = 'A';
    stdout.printf("%s\n", a);
}

-- Jim

On Tue, Jun 21, 2011 at 12:27 AM, Christian Siefkes
<[email protected]>wrote:

> On 06/21/2011 01:29 AM, Jonathan Ryan wrote:
> > Also remember that "[t]he data type for strings is string. Vala strings
> are UTF-8 encoded and immutable." [
> http://live.gnome.org/Vala/Tutorial#Strings]
> > If they are to be immutable, assigning strings must yield shallow copies.
>
> Though they are not *completely* immutable, e.g. calling str._strip() will
> modify a string in place (or so I think).
>
> Best regards
>        Christian
>
> --
> |------- Dr. Christian Siefkes ------- [email protected] -------
> | Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/
> |    Peer Production Everywhere:       http://peerconomy.org/wiki/
> |---------------------------------- OpenPGP Key ID: 0x346452D8 --
> We act for material gain, but also for psychological well-being and
> gratification, and for social connectedness. There is nothing new or
> earth-shattering about this, except perhaps to some economists.
>        -- Yochai Benkler, The Wealth of Networks
>
>
> _______________________________________________
> vala-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
>
>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to