http://d.puremagic.com/issues/show_bug.cgi?id=9183

           Summary: Add a Nullable.get(x) overload
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from [email protected] 2012-12-18 20:16:08 PST ---
I suggest to add an optional argument to Nullable.get() (similar to associative
array get()), that returns the given datum if the nullable is empty. This
overload with one argument is nothrow:


import std.typecons;
nothrow void main() {
    Nullable!int n;
    int x = n.get(10); // x becomes 10.
}



See also Issue 9086

This idea is meant to allow some usage of Nullable in nothrow function, and to
make Nullable more handy to use in some cases.

This idea is similar to the getOrElse method of the Option Scala object:
http://www.scala-lang.org/api/current/scala/Option.html

See also in that module how many methods Scala Option has to make its usage
more handy and increase safety in absence of null.

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

Reply via email to