throws Exception in method

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 8 02:26:10 PDT 2014


On Thursday, 8 May 2014 at 09:15:16 UTC, amehat wrote:
> Hello everyone,
>
> in java, you can have exceptions on methods.
> Thus we can write:
> public static void control (String string) throws
> MyException {}
>
> Is that possible in D and if so how does it work? If I write 
> this D:
>
> public void testMe () throws MyException {}
>
> The compiler refuses to compile.
>
> What is the proper behavior for this D?
>
> thank you

All functions/methods can throw in D, unless they are marked 
nothrow.


More information about the Digitalmars-d-learn mailing list