Re: [Vala] Handling strings
- From: Al Thomas <astavale yahoo co uk>
- To: Sascha Manns <Sascha Manns mailbox org>, vala-list <vala-list gnome org>
- Subject: Re: [Vala] Handling strings
- Date: Wed, 19 Apr 2017 13:04:09 +0000 (UTC)
From: Sascha Manns <Sascha Manns mailbox org>
Sent: Wednesday, 19 April 2017, 13:42
Subject: Re: [Vala] Handling strings
I tried it out in that way:
// Constants used by create_publication_core
private string _filename;
private string _path;
private const string REV_HIST = "Revision_History.xml";
private const string AUTHOR_GROUP = "Author_Group.xml";
private const string ENTITY_FILE_SUFFIX = ".ent";
private const string DIRECTORY_SEPARATOR_CHAR = "/";
private const string ENTITY_FILE_LOCAL = {get {_filename =
publication_title + ENTITY_FILE_SUFFIX; return _filename;}}
The compiler says:
core/create_publication_core.vala:51.48-51.48: error: syntax error,
expected `}'
private const string ENTITY_FILE_LOCAL = {get {_filename =
publication_title + ENTITY_FILE_SUFFIX; return _filename;}}
^
Maybe i miss anything?
You've added 'const'. It should be:
private string ENTITY_FILE_LOCAL = {get {_filename =
publication_title + ENTITY_FILE_SUFFIX; return _filename;}}
Constants do not change during the running of the program. They can, however,
be concatenated at compile time. So you could do:
private const string PATH = DIRECTORY_SEPARATOR_CHAR + AUTHOR_GROUP;
If the field is changeable during the running of the program then it shouldn't
be marked as 'const'.
By the way, GLib has a constant already for directory separator:
https://valadoc.org/glib-2.0/GLib.Path.DIR_SEPARATOR.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]