Skip to content

Instantly share code, notes, and snippets.

@zerokarmaleft
Created September 26, 2011 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zerokarmaleft/1242899 to your computer and use it in GitHub Desktop.
Save zerokarmaleft/1242899 to your computer and use it in GitHub Desktop.
accessing clojure's PersistentHashMap from jruby
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