[Vala] Cannot have field and method with the same name



Hi,

I have a class that contains a field and method with the same name,
and Valac does not like it. What is the reason? Other languages
(C#/Java) allow it. You have to use () for method so you know whether
you access method or field.

public class Foo {
  public boolean stop = true;

  public boolean stop() {
    return true;
  }
}

anatol:vala $ valac a.vala
a.vala:4.3-4.21: error: `Foo' already contains a definition for `stop'
  public boolean stop() {
  ^^^^^^^^^^^^^^^^^^^
a.vala:2.3-2.21: note: previous definition of `stop' was here
  public boolean stop = true;
  ^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)



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