Example #1
0
    @Specialization
    public NilPlaceholder each(VirtualFrame frame, RubyHash hash, RubyProc block) {
      for (Map.Entry<Object, Object> entry : hash.storage.entrySet()) {
        yield(frame, block, entry.getKey(), entry.getValue());
      }

      return NilPlaceholder.INSTANCE;
    }
Example #2
0
    @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;
    }