Re: [Vala] "this" in objects



On Wed, 2011-08-03 at 20:39 +0200, Pavol Klačanský wrote:
Hi,

why somebody uses this. prefix and somebody doesn't, I have tried and it 
worked with or without it

1.

class Test {
  private int i;
  public Test(int i) {
     this.i = i; // field is assigned by variable
     i = this.i; // variable is assigned by field
  }
}

2.

class Test {
  private Test? next;
  public void add_to_chain(Test head) {
    while(head.next != null)
      head = head.next;
    head.next = this;
  }
}

Regards

Attachment: signature.asc
Description: This is a digitally signed message part



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