On Wednesday, 26 October 2016 at 08:19:46 UTC, Andrea Fontana wrote:
On Wednesday, 26 October 2016 at 03:58:05 UTC, Stefam Koch wrote:
On Tuesday, 25 October 2016 at 17:19:26 UTC, Jacob Carlborg wrote:

Very impressive :)

Thanks.

I just got the following code to compile and execute correctly.

bool strEq(string a, string b)
{
    if (a.length != b.length)
    {
        return false;
    }
    uint length = cast(uint) a.length;

    while(length--)
    {
        auto c1 = a[length];
        auto c2 = b[length];
        if (c1 != c2)
        {
            return false;
        }
    }

    return true;
}

static assert(!strEq("Hello","World"));
static assert(strEq("World","World"));

I used the generated bytecode to make == for strings work.

Why did you cast size_t to uint in this example?

Currently I am limited to 32bit Arithmetic.
Changing this is on the Table but I have not gotten to it yet.

Reply via email to