[haXe] Getters, Setters and Interfaces

Glen Blanchard blanchard.glen+haxe at gmail.com
Thu Aug 2 06:38:03 CEST 2007


Hi Luke,

Changing Testable to the following works for me.

interface Testable
{
    public var p(getP, setP) : Int;
}

Glen.

On 8/2/07, Luke Schreur <luke.schreur at profero.com.au> wrote:
>
> Hi guys,
>
> I need to add a property, to be implemented as a getter/setter, to an
> interface and after doing do I can't seem to get the class that implements
> the interface to work.
>
> This is my interface:
>
> interface Testable
> {
> public var p : Int;
> }
>
> and this is my class:
>
> class Test implements Testable
> {
> private var m_p : Int;
>
>
> public var p(getP, setP) : Int;
>
>
> public function getP() : Int
> {
>  return m_p;
> }
>
>
> public function setP(p : Int) : Int
> {
>  m_p = p;
>
>
>  return m_p;
> }
>
>
> public function new()
> {
>  p = 0;
> }
>
>
>     public static function main()
>     {
>         var t : Test = new Test();
>     }
> }
>
> When I compile I get the following error:
>
> Field p has different property access than in Testable
>
> What am I doing wrong here?
>
> Thanks!
>
>
> PS: Sorry to bombard this list with stupid questions, just trying to get
> up and running.
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070802/7a2d9bef/attachment-0001.htm


More information about the Haxe mailing list