Here's a little trick you might like: [code] errordomain MyError { FAILED; } T throwerror<T> (string str) throws Error { throw new MyError.FAILED (str); } int func () { int? i = null; int j = i ?? throwerror<int> ("hello"); return j; } [/code]
Would this also be a valid way to check for null? T unbox<T>(T? v, string str) { if (v == null) throw new MyError.FAILED(str); return (T)v; }
Attachment:
smime.p7s
Description: S/MIME cryptographic signature