December 19, 2012 [Issue 9183] New: Add a Nullable.get(x) overload | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from bearophile_hugs@eml.cc 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: ------- |
February 16, 2013 [Issue 9183] Add a Nullable.get(x) overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9183 Nick Sabalausky <cbkbbejeap@mailinator.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cbkbbejeap@mailinator.com --- Comment #1 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2013-02-16 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: ------- |
Copyright © 1999-2021 by the D Language Foundation