Created
November 16, 2015 10:03
-
-
Save wjlroe/063313e9b310217ae54e to your computer and use it in GitHub Desktop.
Ruby's (2.3.0) dig and Clojure's get-in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def people [{:name "Will" | |
:health 1} | |
{:name "Not Will" | |
:health -10}]) | |
(get-in people [0 :name]) #=> "Will" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people = [ | |
{name: "Will", health: 1}, | |
{name: "Not will", health: -1} | |
] | |
people.dig(0, :name) #=> "Will" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment