Re: [Vala] Handling strings



From: Sascha Manns <Sascha Manns mailbox org>
Sent: Wednesday, 19 April 2017, 12:43
Subject: [Vala] Handling strings

I'm getting the information that the access to instance member is denied.


How can i concat strings in Vala?

Concatenation of variables is done at run time, so you either need to
make the strings constant or use properties to allow the concatenation to
occur at run time:

void main () {
     var a = new Test ();
  print (@"Extension: $(Test.ext)\n");
  print (@"Filename: $(a.filename)\n");
  print (@"Path: $(a.path)\n");
}

class Test {
  public const string ext = ".ext";
  private string _filename;
  public string filename {get {_filename = "test" + ext; return _filename;}}
  private string _path;
  public string path {get {_path = "/full/path/" + filename; return _path;}}
}


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