Function overloading quiz
What is the output of the following code?
import std.uni : toLower;
int fun(string s)
in (s == s.toLower())
{
return -42;
}
string fun(int x)
out (; x >= 0)
{
x *= -42;
return "Hello World!";
}
void main()
{
import std.stdio : writeln;
writeln(fun("hello world!"));
writeln(fun(-42));
}
What is the output for the snippet above?
Runtime error at 1st call of fun() | The call | |
Runtime error at 2nd call of fun() | The call | |
hello world! | The call | |
-42 | The call | |
-42 Hello World! | Correct! |