Thursday, May 16, 2024
HomeGolangGolang perform parameters - Getting Assist

Golang perform parameters – Getting Assist


Why we dont use var key phrase in perform parameters in golang?

Hello @Ash ,

Welcome to the discussion board.

Why do you anticipate that the var key phrase can/shall be used inside perform parameters?
What profit would the var key phrase have in perform parameter lists?

Coz i believe that var is one thing that signifies that it could actually change its worth,so a perform parameter may change its worth whereas the perform is being executed… Iam in all probability getting it utterly incorrect.

In Go all parameters are handed by Worth. Does no exists the idea “cross by reference”.so you need to cross a pointer to have the “var” behaviour you might be mentioning

I imply in golang var key phrase is used to declare a variable of any sort,so aren’t perform parameters variables… Why we keep away from utilizing var key phrase in perform parameter?

func do (a, b int)

That is positive.

However this one is just not

func do (var a int, var b int)

Possibly as a result of perform parameters are at all times variables. They will’t be const, so there’s no want for additional annotation.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments