[Vala] Cannot have field and method with the same name
- From: Anatol Pomozov <anatol pomozov gmail com>
- To: vala-list gnome org
- Subject: [Vala] Cannot have field and method with the same name
- Date: Fri, 3 Dec 2010 15:38:38 -0800
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]