Re: [Vala] Array as big as an enum



Hi,

and last but not least one may overwrite the to_string method to get own
strings like this:

enum Test {
  ONE,
  TWO;
  public string to_string() {
    switch(this) {
      case ONE:
        return "enum number one";
      case TWO:
        return "enum number two";
      default:
        return "weeeee, unknown enum number "+((int)this).to_string();
    }
  }
}

This is for example VERY nice to convert error numbers to error strings.

-- 
Bernhard


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