Reputation: 21
MY Code:
String fun(int age, String name)
{
print("hi");
return 'My name is $name and i am $age';
}
void main()
{
print("Hello! Good Morning good people.");
fun(21,"Jasraj");
}
Output:
Hello! Good Morning good people. hi
My Question: Why return statement is not working?
See Image
Upvotes: 2
Views: 98
Reputation: 1
in void main, return only works if you print it so print(fun(Int variable, String Variable))
Upvotes: 0
Reputation: 63864
fun
return a string and to show, you need to wrap with print method.
void main() {
print("Hel`enter code here`lo! Good Morning good people.");
print(fun(21, "Jasraj"));
}
Or
String result = fun(21, "Jasraj");
print(result);
Upvotes: 3