org.jruby.Ruby.newLightweightStopIterationError()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.jruby.Ruby.newLightweightStopIterationError方法的一些代码示例,展示了Ruby.newLightweightStopIterationError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newLightweightStopIterationError方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newLightweightStopIterationError

Ruby.newLightweightStopIterationError介绍

[英]Generate a StopIteration exception. This differs from the normal logic by avoiding the generation of a backtrace. StopIteration is used by Enumerator to end an external iteration, and so generating a full backtrace is usually unreasonable overhead. The flag -Xstop_iteration.backtrace=true or the property jruby.stop_iteration.backtrace=true forces all StopIteration exceptions to generate a backtrace.
[中]生成StopIteration异常。这与正常逻辑不同,因为它避免了回溯的生成。枚举器使用StopIteration结束外部迭代,因此生成完整回溯通常是不合理的开销。标志-Xstop_迭代。backtrace=true或属性jruby。停止迭代。backtrace=true强制所有StopIteration异常生成回溯。

代码示例

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private IRubyObject returnValue(IRubyObject value) {
  // if it's the NEVER object, raise StopIteration
  if (value == NEVER) {
    doneObject = value;
    throw runtime.newLightweightStopIterationError("stop iteration");
  }
  
  // if it's an exception, raise it
  if (value instanceof RubyException) {
    doneObject = value;
    throw new RaiseException((RubyException)value);
  }
  
  // otherwise, just return it
  return value;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private void checkIndex() throws RaiseException {
    if (index >= array.size()) throw runtime.newLightweightStopIterationError("stop iteration");
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private void checkIndex() throws RaiseException {
    if (index >= array.size()) throw runtime.newLightweightStopIterationError("stop iteration");
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private IRubyObject returnValue(IRubyObject value) {
  // if it's the NEVER object, raise StopIteration
  if (value == NEVER) {
    doneObject = value;
    throw runtime.newLightweightStopIterationError("stop iteration");
  }
  
  // if it's an exception, raise it
  if (value instanceof RubyException) {
    doneObject = value;
    throw new RaiseException((RubyException)value);
  }
  
  // otherwise, just return it
  return value;
}

相关文章

Ruby类方法