www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2017] New: Dynamic array creation

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2017

           Summary: Dynamic array creation
           Product: D
           Version: 2.012
          Platform: All
               URL: http://www.digitalmars.com/d/2.0/arrays.html
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: gide nwawudu.com


To create a dynamic arrays the following first example is ok, but the second
fails, maybe the second method should compile? Also, the documentation does not
mention the "abc"[] method to create a dynamic array.

Example
-------
auto str1 = "abc"[]; // OK
auto str2 = ['a', 'b', 'c'][]; // Error, invalid syntax?


-- 
Apr 20 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2017





------- Comment #1 from gide nwawudu.com  2008-10-25 05:48 -------
The following example now compiles in DMD v2.020, but it wasn't mentioned in
the changelog, but the docs don't mention "abc"[] as a method of creating
dynamic arrays.

test.d
------
import std.stdio;

void main() {
        auto str1 = "abc"[]; // OK
        auto str2 = ['a', 'b', 'c'][];
        writefln(typeof(str1).stringof);
        writefln(typeof(str2).stringof);
}

Output
------
invariant(char)[]
char[]


-- 
Oct 25 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2017


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED


--- Comment #2 from yebblies <yebblies gmail.com> 2011-06-10 05:40:00 PDT ---
This now works as array literals are dynamic arrays.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2011