On Sat, Aug 4, 2012 at 6:40 PM, Ralph Main <rmain1...@live.com> wrote:
Hello Ralph, > The module std.random documentation doesn't work as per the examples. > The example shows getting a random number by the following code does not > work: (snip) Both code samples you gave work perfectly for me (DMD 2.060, Linux). Which version are you using? > The new keyword was not in the example, and the original example code would > not work. When looking at the source code of the std libraries, a struct > can contain a constructor, so therefore it is similar to a class; and on a > whim I tried the new keyword. So I thought I would pass this information > along. I looked at other posts in the forum, but didn't see anyone using > the new keyword. Is this a bug, or a change to the D language > implementation? The 'new' keyword has been in D from the beginning, but it's used to create classes (which are reference types in D) or values on the heap. Most of the time, you create a struct like this: MyStruct s = MyStruct(arguments); For a class: MyClass c = new MyClass(arguments); See: http://dlang.org/expression.html#NewExpression