Re: I can't get passing an array by reference to work anymore...

2015-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 September 2015 at 02:37:22 UTC, TheGag96 wrote: So I'm just doing a small test program here: http://pastebin.com/UYf2n6bP (I'm making sure I know quicksort for my algorithms class, I know functionally this won't work as-is) I'm on Linux, 64-bit, DMD 2.068.1, and when I try to

Re: I can't get passing an array by reference to work anymore...

2015-09-24 Thread Ali Çehreli via Digitalmars-d-learn
On 09/24/2015 09:14 PM, Mike Parker wrote: > I'm seeing the same error, but I haven't yet determined why. It is because rvalues cannot be bound to 'ref' parameters: void quickSort(ref int[] arr) { // ... quickSort(arr[0..wall]); // This slice is rvalue quickSort(arr[wall+1..$]);

I can't get passing an array by reference to work anymore...

2015-09-24 Thread TheGag96 via Digitalmars-d-learn
So I'm just doing a small test program here: http://pastebin.com/UYf2n6bP (I'm making sure I know quicksort for my algorithms class, I know functionally this won't work as-is) I'm on Linux, 64-bit, DMD 2.068.1, and when I try to compile this I'm getting: quicksort.d(18): Error: function

Re: I can't get passing an array by reference to work anymore...

2015-09-24 Thread Mike Parker via Digitalmars-d-learn
On Friday, 25 September 2015 at 02:37:22 UTC, TheGag96 wrote: What's the problem here? I SWEAR I've passed arrays by reference before just like this. Thanks guys. I'm seeing the same error, but I haven't yet determined why. At any rate, this works: ``` import std.stdio; void append(ref

Passing an array by reference?

2014-07-24 Thread Rishub Nagpal via Digitalmars-d-learn
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?

Re: Passing an array by reference?

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:06:00 UTC, Rishub Nagpal wrote: 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