Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two discussions of copying mutable objects in episode 3? #616

Open
edbennett opened this issue Jan 31, 2019 · 1 comment
Open

Two discussions of copying mutable objects in episode 3? #616

edbennett opened this issue Jan 31, 2019 · 1 comment

Comments

@edbennett
Copy link
Contributor

@edbennett edbennett commented Jan 31, 2019

I was tripped up teaching this week when working through episode 3—there's a long sidebar talking about mutability, most of which is devoted to showing how to make copies of lists without accidental aliasing. Then a few paragraphs later, there's an almost identical discussion of avoiding this problem, with a different example, and avoiding the word mutable. Having not noticed this beforehand, I ended up repeating myself largely, since I assumed that there would be something new to say, and then there wasn't.

Should these two sections be consolidated into one discussion? (Perhaps by removing "how to correctly create copies" from the sidebar, and mentioning that it will be discussed further down the page?) Removing some duplicated content would also go a (very small) way towards helping with the time constraints with this long lesson.

@AnthonyOfSeattle
Copy link

@AnthonyOfSeattle AnthonyOfSeattle commented Jul 12, 2019

I second this idea. I'm very fond of teaching the difference between copying and just assigning a list to a new variable name. Especially since it seems like something previous users of R could get caught on, where its less of an issue. However, Ch-Ch-Ch-Ch-Changes does seem like it can be split up. Maybe we could try something like this?

  1. Move the first two paragraphs of Ch-Ch-Ch-Ch-Changes, which talk about mutability, to be part of the standard lesson right after
name = 'Darwin'
name[0] = 'd'
  1. Drop the salsa example of Ch-Ch-Ch-Ch-Changes. I think it is a nice example but seems to be a lot of typing to get the premise across.

  2. Add an assignment example to the mutability section at the bottom of the lesson

odds = [1, 3, 5, 7, 9]
primes = odds
primes[-1] = 11
print('primes:', primes)
print('odds:', odds)
primes.append(2)
print('primes:', primes)
print('odds:', odds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants