Re: [Vala] What is the right syntax for defining pointers or references or "aliases" in Vala ?



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
<christian siefkes net>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 ------- christian siefkes net -------
| 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
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]