Skip to content

Instantly share code, notes, and snippets.

@barkanido
Created December 26, 2019 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barkanido/c3def6d4433cb6a65f617e1ed014c0f4 to your computer and use it in GitHub Desktop.
Save barkanido/c3def6d4433cb6a65f617e1ed014c0f4 to your computer and use it in GitHub Desktop.
(defprotocol Talker
(talk [this msg]))
(defrecord Hero
[name type position health objects]
Talker
(talk [this msg]
(println (:name this) ":" msg)))
(->Hero "Bad Guy" :warrior {:x 11 :y 344} 93 [:sword :dagger])
(map->Hero {:name "Bad Guy" :type :warrior})
(->Hero "Bad Guy" :warrior {:x 11 :y 344} 93 [:sword :dagger])
(map->Hero {:name "Bad Guy" :type :warrior})
{:health nil, :name "Bad Guy", :objects nil, :position nil, :type :warrior}
(Hero.)
(Hero. "Bad Guy" :warrior {:x 11 :y 344} 93 [:sword :dagger])
(let [max (Hero. "Bad Guy" :warrior {:x 11 :y 344} 93 [:sword :dagger])]
(talk max "Don't mess with me."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment