Return to Video

ShorterShortcut (Video Version)

  • 0:02 - 0:05
    Let's animate Winston
    using the shortcuts that you just learned.
  • 0:05 - 0:08
    So, here we've got Winston with his eyes
  • 0:08 - 0:10
    and we've got this eyeSize variable.
  • 0:10 - 0:13
    So if we wanted to make
    Winston's eyes get bigger
  • 0:13 - 0:16
    we could just say "eyeSize += 1,"
  • 0:16 - 0:19
    adding one pixel to the size of the eyes
  • 0:19 - 0:21
    each time, and whoah!
    Look at it, it's buggin' out!
  • 0:21 - 0:24
    Let's restart -- whoah! Bug out! Bug Out!
  • 0:25 - 0:26
    Now, that's pretty cool.
  • 0:26 - 0:28
    And, it turns out in programming
  • 0:28 - 0:30
    we actually add one to variables a lot.
  • 0:30 - 0:32
    Maybe while animating but also,
  • 0:32 - 0:34
    you'll see there's a lot of other reasons
  • 0:34 - 0:36
    why we add one to variables later.
  • 0:36 - 0:39
    Programmers got bored
    of writing "+= 1" all the time
  • 0:39 - 0:41
    because programmers
    get bored of silly things.
  • 0:41 - 0:44
    So they came up with
    a shorter way of writing it.
  • 0:44 - 0:49
    So instead of "eyeSize += 1,"
    we could just write "eyeSize++"
  • 0:49 - 0:52
    You see, it will do
    exactly the same thing.
  • 0:52 - 0:54
    It's just a shorter way of doing it.
  • 0:55 - 0:58
    And not only do we use
    this in programming,
  • 0:58 - 1:00
    Now most programmers
    use it in everyday speech.
  • 1:00 - 1:03
    Because pretty much
    we're all familiar with ++.
  • 1:03 - 1:05
    And it's an easy way of saying
  • 1:05 - 1:07
    that you're making
    something a little bigger.
  • 1:07 - 1:10
    So if we went to Winston's birthday party,
  • 1:10 - 1:13
    we might say, "Oh, happy birthday
    Winston, Winston++!"
  • 1:13 - 1:15
    Because Winston just got a year older.
  • 1:15 - 1:18
    Or if we just learned a new fact you might be like,
  • 1:18 - 1:21
    "Oh, go us, intelligence++!"
  • 1:22 - 1:23
    That's pretty fun.
  • 1:23 - 1:26
    So when should you use ++ versus +=?
  • 1:26 - 1:30
    Well, I think for animation
    it's cool to use +=, because then
  • 1:30 - 1:32
    you can use the number scrubber
    and you can be like,
  • 1:32 - 1:35
    "Whoah! Let's make it -- whoah whoah!
    That was awesome!
  • 1:35 - 1:38
    Let's make it really crazy,
    really different!
  • 1:38 - 1:41
    Oh! (laughter) See how fun that is?
  • 1:42 - 1:44
    But, you know, depending
    on what you're doing
  • 1:44 - 1:47
    it might be convenient just to say "++."
  • 1:47 - 1:50
    And you'll see later
    that there's lots of times
  • 1:50 - 1:52
    when you might want to add one
  • 1:52 - 1:53
    to variables, not just for animation,
  • 1:53 - 1:56
    where the ++ operator
    could become even more useful.
  • 1:56 - 1:58
    So just keep that in mind
    when you see that ++
  • 1:58 - 2:01
    and try using it in your everyday speech.
Title:
ShorterShortcut (Video Version)
Description:

more » « less
Video Language:
English
Duration:
02:01

English subtitles

Revisions