
Want this course?
Add cocoa
Let's add a new ingredient, namely cocoa.
Warmup
Just to remember how to do it, let's add a new ingredient. Cocoa
powder is stored in the pantry and is scoopable. Use the keyword :cocoa
to name it.
To navigate to this point in the introduction-to-clojure
repo:
$CMD git checkout -f 3.1
Watch me
Luckily, all of the refactoring we did made it very easy to add new
ingredients. We just have to add :cocoa
to the collections for scooped-ingredients
and pantry-ingredients
.
To navigate to this point in the introduction-to-clojure
repo:
$CMD git checkout -f 3.2
We can test this at the REPL. Let's run a REPL:
$CMD lein repl
Then, let's fetch some cocoa and add it to the bowl.
(fetch-ingredient :cocoa 4)
(add :cocoa 3)
(status)
Code is available: lispcast/introduction-to-clojure
Code for this particular lesson is available at the 3.1
branch.
You can checkout the code in your local repo with this command:
$CMD git clone https://github.com/lispcast/introduction-to-clojure.git
$CMD cd introduction-to-clojure
$CMD git checkout -f 3.1