Passing an array by reference?

Rishub Nagpal via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 24 09:05:59 PDT 2014


   1 class Test
   2 {
   3     int[][] array;
   4     this(ref int[][] d)
   5     {
   6         array = d;
   7     }
   8
   9 }
  10
  11 void main()
  12 {
  13     Test t = new Test([[1,1],[1,1]]);   //does not compile
  14 }
  15


what is the best way to pass a literal ([[1,2],[3,4]]) by 
reference? Is using ref the best way? I am still a bit fuzzy with 
in/out and scope



More information about the Digitalmars-d-learn mailing list