- 1

Golang

I didn't understood this return function https://code.sololearn.com/crCzZWsD8tm1/?ref=app

27th Mar 2022, 11:08 AM
HELL DRAGON
HELL DRAGON - avatar
2 Respostas
+ 2
Chetan kumar That is not a return function. That's a function which returns value so we have used return keyword. "sum" is a function which has return type int means integer value will be return. return can be used in 2 ways, when you want to return a value back to the function and when you want to stop execution at some condition. So if you write "return 10" then 10 will be return to the function. if you write only "return" then further execution of a function will be stop there. In your example you didn't print returned value. So to print returned value do this: fmt.Println(sum(3,2))
27th Mar 2022, 11:17 AM
A͢J
A͢J - avatar
+ 2
Thank u
27th Mar 2022, 11:20 AM
HELL DRAGON
HELL DRAGON - avatar