Skip to content

Commit

Permalink
datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
jflinchbaugh committed Feb 3, 2018
1 parent b60f260 commit 373a6c6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/koans/19_datatypes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,32 @@
(deftype Razzie [category]
Award
(present [this recipient]
__))
(print (str "You're really the "
(.category this)
", "
recipient
"... sorry."))))

(meditations
"Holding records is meaningful only when the record is worthy of you"
(= __ (.prize (Nobel. "peace")))
(= "peace" (.prize (Nobel. "peace")))

"Types are quite similar"
(= __ (.prize (Pulitzer. "literature")))
(= "literature" (.prize (Pulitzer. "literature")))

"Records may be treated like maps"
(= __ (:prize (Nobel. "physics")))
(= "physics" (:prize (Nobel. "physics")))

"While types may not"
(= __ (:prize (Pulitzer. "poetry")))
(= nil (:prize (Pulitzer. "poetry")))

"Further study reveals why"
(= __
(= [true false]
(map map? [(Nobel. "chemistry")
(Pulitzer. "music")]))

"Either sort of datatype can define methods in a protocol"
(= __
(= "Congratulations on your Best Picture Oscar, Evil Alien Conquerors!"
(with-out-str (present (Oscar. "Best Picture") "Evil Alien Conquerors")))

"Surely we can implement our own by now"
Expand Down

0 comments on commit 373a6c6

Please sign in to comment.