Search code examples
clojurejruby

Clojure in JRuby; Java::ClojureLang::PersistentArray to Ruby Hash


How do I translate the Java::ClojureLang::PersistentArray map into a ruby array? As you'll see below, I get a hash-like return with a Java::ClojureLang::Keyword as the key and the parts of the set as a value.

require 'jrclj'
clj = JRClj.new
clj._import "tester.core"

x = clj.check("66 61 value")

binding.pry

#PRY
[1] pry(main)> x
 => {97=>{#<Java::ClojureLang::Keyword:0x6d6b6e88>=>66, #<Java::ClojureLang::Keyword:0x4d426dd8>=>61, #<Java::ClojureLang::Keyword:0x481d2264>=>{#<Java::ClojureLang::Keyword:0x47c27c3c>=>"value",

[2] pry(main)> x.class
=> Java::ClojureLang::PersistentArrayMap

Solution

  • since it implements Map just do a x.values.to_a