Mutable and Immutable with reference to functions.

This is a slight aside just to explain what we mean when we say an int and string are immutable, but lists and dictonaries are mutable.

The second video goes on to explain how this is relevant when we pass variables into functions.

We need this in our Soduko solver because we will be passing lists around all the time, and it is important to realise we are actually only passing references to the list around and not copying the whole thing. Thus when we change the list in the function, we have actually changed the list in main as well, because it is the same list.  !!!!  Wow !!!!

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s