In reply to Harshad:
I think the issue of using ref in this particular case is that at somepoint you’ll do sample(x[i][j]) and the LRM does not allow ref for packed arrays slices, According to the LRM
Only the following shall be legal to pass by reference:
— A variable,
— A class property,
— A member of an unpacked structure, or
— An element of an unpacked array.
In general I believe ref is used in a method to improve performance for example when passing large structures/arrays as arguments, you can look for details in section 13.5.2 Pass by reference.
HTH,
-R