title: Return int reference in vala
body: <p>I have a class that has fields and I want call a method of this class and get the reference to one of the fields (not the value!!). Something like this:</p>
  
  <pre><code>class Test : Object{
      uint8 x;
      uint8 y;
      uint8 z;
  
      uint8 method(){
          if (x == 1){
              return y;
          }else if (x == 2){
              return z;
          }
      }
  
      public static void main(string[] args){
          uint8 i = method(); // get reference to y or z
          i++;  //this must update y or z
      }
  }
  </code></pre>
  
  <p>In C would be:</p>
  
  <pre><code>int&amp; method()
  {
      if (x == 1){
          return y;
      }else if (x == 2){
          return z;
      }
  }
  </code></pre>
  
  <p>How can I achieve this in vala?</p>
  
  <p>Edit: I'm trying use pointers, I have the following</p>
  
  <pre><code>public class Test : Object {
  
      private Struct1 stru;
  
      struct Struct1{
          uint8 _a;
  
  
          public uint8 a{
              get{ return _a; }
              set{ _a = value; }
          }
  
  
          public Struct1(Struct1? copy = null){
              if (copy != null){
                  this._a = copy.a;
              }else{
                  this._a = 0;
              }
          }
  
          public uint8* get_aa(){
              return (uint8*)a;
  
          }
      }
  
      public void get_pointer(){
          uint8* dst = stru.get_aa();
      }
  
      public static int main (string[] args){
  
  
          Test t = new Test();
  
          return 0;
      }
  
  }
  </code></pre>
  
  <p>but when I compile I get</p>
  
  <pre><code>/home/angelluis/Documentos/vala/test.vala.c: In function ‘test_struct1_get_aa’:
  /home/angelluis/Documentos/vala/test.vala.c:130:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    result = (guint8*) _tmp1_;
             ^
  Compilation succeeded - 2 warning(s)
  </code></pre>
  
  <p>Why? I am returning an uint8* type and I attempt to store it in an uint8* pointer.</p>