diff test/slices.d @ 1:c53b6e3fe49a trunk

[svn r5] Initial commit. Most things are very rough.
author lindquist
date Sat, 01 Sep 2007 21:43:27 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/slices.d	Sat Sep 01 21:43:27 2007 +0200
@@ -0,0 +1,34 @@
+module slices;
+
+void main()
+{
+    //char[] a = "hello world";
+    //char[5] b = a[0..5];
+
+    //char* cp = a.ptr;
+    //char[] c = cp[0..1];
+}
+
+char[] first5(char[] str)
+{
+    char* p = str.ptr;
+    return p[0..5];
+}
+
+int[] one()
+{
+    static int i;
+    return (&i)[0..1];
+}
+
+void[] init()
+{
+static char c;
+return (&c)[0 .. 1];
+}
+
+void[] init2()
+    {   static char c;
+
+    return (cast(char *)&c)[0 .. 1];
+    }
\ No newline at end of file