Bitpath

Lesson 1 · Unit 02

The unified diff

Hunks, plus and minus, before and after

12 exercisesabout 3 min

What you practise

  • Hunks and their headers, added, removed and context lines, a rename, reading the before and the after out of one diff

Try a question from this lesson

Pick one

A colleague sends you this change. Nobody has explained the format yet. What did the change do?

--- a/cart.py
+++ b/cart.py
@@ -1,5 +1,5 @@
-def total(prices):
+def total(prices, tax=0):
     result = 0
     for p in prices:
         result += p
-    return result
+    return result + tax

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Anatomy of a unified diff

A diff lists hunks: runs of changed lines with a little context around them.

The first character of each line is a code. A space means unchanged. A minus means only in the old file. A plus means only in the new file.

An edited line appears twice: once with a minus, once with a plus.

--- a/app.py        old file
+++ b/app.py        new file
@@ -1,2 +1,2 @@     where the hunk is
 def run():         context
-    start()        removed
+    start(debug)   added

10 more exercises in the app

  • 4× type the answer
  • 1× true or false
  • 1× fill the blanks
  • 3× multiple choice
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy