Last active
August 29, 2015 14:13
-
-
Save darinwilson/bef5fd5bb4ce8651257a to your computer and use it in GitHub Desktop.
RubyMotion Android: can't convert java.util.HashMap to Ruby Hash
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
# Update: there's an issue open in RubyMotion for this, so hopefully it will get resolved soon. | |
# | |
# http://hipbyte.myjetbrains.com/youtrack/issue/RM-725 | |
# | |
# In the meantime, here's a workaround: https://gist.github.com/darinwilson/26c8b573a65d8bc4c64b | |
# if you create a Ruby Hash... | |
ruby_hash = { foo: "bar" } | |
# ...you can call Ruby methods... | |
ruby_hash.has_key?(:foo) | |
# ...and java.util.HashMap methods | |
ruby_hash.containsKey(:foo) | |
# but if you create a Java HashMap... | |
hash = Java::Util::HashMap.new | |
hash.put("foo", "bar") | |
# you can't call Ruby methods | |
hash["foo"] # <- raises com.rubymotion.NoMethodError | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment