Probable C# 6.0 features
Simen Kjærås
simen.kjaras at gmail.com
Wed Dec 11 04:55:50 PST 2013
On 2013-12-11 00:21, Idan Arye wrote:
> if(int b=a.tryParse!int()){
> //some code that uses `b`
> }
>
> if `a` is "0" we won't enter the then-clause even though we managed to
> parse. This is why we don't have this `tryParse` function in D...
Not just that - how would you signal that a is an invalid value? Throw
an exception?
A solution would be:
if (Option!int b = a.tryParse!int) {
// Use b in here.
}
--
Simen
More information about the Digitalmars-d
mailing list