On Thursday, 28 March 2013 at 21:16:32 UTC, Chris Cain wrote:
I am completely confused as to why you're doing what you are doing ... std.conv does work (and in the case you've listed, is unnecessary anyway). Try this:

import std.stdio, std.conv;

void main() {
    ubyte[] buffer;
    buffer ~= 5; // Simple solution
    buffer ~= to!ubyte(6); // Proper usage of "to"
    writeln(buffer);
}

This is not what I'm trying to achieve.
This gives me an array with two elements, [5, 6]. What I want is to append the 4 bytes that make up one integer value, which using your values means buffer should hold a total of 8 bytes (two integers).

H. S. Teoh answered well on how this can be achieved, although my feedback was not really meant as a question of "how is this done?", more of "why is this done like this, couldn't it be done much easier?".

Reply via email to