Created
September 26, 2011 18:07
-
-
Save zerokarmaleft/1242899 to your computer and use it in GitHub Desktop.
accessing clojure's PersistentHashMap from jruby
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
require 'java' | |
require 'clojure' | |
module Clojure | |
include_package 'clojure.lang' | |
end | |
foo = Clojure::PersistentHashMap.create(:a, 1) | |
# => {:a=>1} | |
foo.assoc(:e, 5) | |
# => {:a=>1, :e=>5} | |
foo | |
# => {:a=>1} | |
bar = Clojure::PersistentHashMap.create(:b, 2, :c, 3) | |
# => {:b=>2, :c=>3} | |
foobar = Clojure::PersistentHashMap.create(foo.merge(bar)) | |
# => {:a=>1, :b=>2, :c=>3} | |
foobar.invoke(:c) | |
# => 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment