Surely this should be valid Java? Have I got the syntax slightly wrong?
return (url != null) ? url : (throw new NotFoundException("No url"));
If not I suppose I’d have to do this:
if(url == null)
throw new NotFoundException("No url");
return url;
Anyone have anything more succinct?
Because you’re not fulfilling the return:
In your case, you’re fulfilling the
value1but notvalue2and instead you’re throwing a new exception.Your actual first code would be translated to