Mercurial > projects > ldc
view test/arrays.d @ 295:895e1b50cf2a trunk
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
There was problems with most non basic types...
Added an option to premake so we can do: premake --target gnu --no-boehm
to disable the Boehm GC.
author | lindquist |
---|---|
date | Mon, 23 Jun 2008 14:48:42 +0200 |
parents | e881c9b1c738 |
children |
line wrap: on
line source
module arrays; extern(C) int printf(char*, ...); void integer() { auto arr = new int[16]; arr[1] = 42; arr[6] = 555; print_int(arr); delete arr; } void floating() { auto arr = new float[6]; arr[1] = 3.14159265; arr[3] = 1.61803399; print_float(arr); delete arr; } void print_int(int[] arr) { printf("arr[%lu] = [", arr.length); for (auto i=0; i<arr.length; i++) printf("%d,", arr[i]); printf("\b]\n"); } void print_float(float[] arr) { printf("arr[%lu] = [", arr.length); for (auto i=0; i<arr.length; i++) printf("%f,", arr[i]); printf("\b]\n"); } void main() { integer(); floating(); }