English subtitles

← 03-55 Accessor or Mutator?

03-55 Accessor or Mutator?

Get Embed Code
7 Languages

Showing Revision 3 created 05/07/2015 by Udacity Robot.

  1. The answer is, it print jello on one line, and then hello on the next line. On
  2. the second line, when we just print out greeting, we can see that it hasn't
  3. changed from the original. We say that it didn't mutate. Instead of modifying
  4. the original string, the replace method returns a new one. This would be like
  5. if you had a mean cat and you told your cat to be nicer. And instead of
  6. becoming nicer, it just gave you a new, nicer cat. That's why we call replace
  7. an accessor method, not a mutator.