I have object which i need to be changed in function. Should i pass it as parameter and return it or pass it as reference and edit inside function?


I have object which i need to be changed in function. Should i pass it as parameter and return it or pass it as reference and edit inside function?

As the title says, let's say i have object o which i need to update inside function.

Now, which way of editing it is better?:

func EditObj(o Object) Object{ //body of function }

OR

func EditObj(o *Object) { //body of function }

Submitted July 17, 2017 at 05:22PM by kerakk19
via reddit http://ift.tt/2uqPWYc

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s