> From: Sascha Manns <sascha.ma...@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;}}
}
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to