@Specialization public RubyArray toArray(RubyHash hash) { final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass()); for (Object key : hash.storage.keySet()) { RubyArray subArray = new RubyArray(getContext().getCoreLibrary().getArrayClass()); subArray.push(key); subArray.push(hash.storage.get(key)); array.push(subArray); } return array; }
@Specialization public RubyArray values(RubyHash hash) { final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass()); for (Object value : hash.storage.values()) { array.push(value); } return array; }
@Specialization public RubyArray map(VirtualFrame frame, RubyHash hash, RubyProc block) { final RubyArray result = new RubyArray(getContext().getCoreLibrary().getArrayClass()); for (Map.Entry<Object, Object> entry : hash.storage.entrySet()) { result.push(yield(frame, block, entry.getKey(), entry.getValue())); } return result; }