digitalmars.D.bugs - [Issue 9183] New: Add a Nullable.get(x) overload
- d-bugmail puremagic.com (31/31) Dec 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9183
- d-bugmail puremagic.com (10/10) Feb 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9183
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: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
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: -------
Dec 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9183
Nick Sabalausky <cbkbbejeap mailinator.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |cbkbbejeap mailinator.com
15:23:31 PST ---
This would indeed be a great thing to have.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2013








d-bugmail puremagic.com