[Issue 13016] New: Can't create std.typecons.Nullable!int from the index variable of a foreach loop

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 1 22:36:55 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13016

          Issue ID: 13016
           Summary: Can't create std.typecons.Nullable!int from the index
                    variable of a foreach loop
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: monkeyworks12 at hotmail.com

import std.typecons: Nullable;

Nullable!int IndexOf(int[] arr, int val)
{
    foreach (i, n; arr)
    {
        if (n == val)
        {
            //Error: inout method
                        //std.typecons.Nullable!int.Nullable.this 
                        //is not callable using a mutable object
            return Nullable!int(i);
        }
    }

    return Nullable!int();
}

--


More information about the Digitalmars-d-bugs mailing list