Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
Ruby::Prism::Result#continuable?
# File tmp/rubies/ruby-4.1.0-preview1/lib/ruby/prism/parse_result.rb, line 990
def continuable?
@continuable
end
Returns true if the parsed source is an incomplete expression that could become valid with additional input. This is useful for REPL contexts (such as IRB) where the user may be entering a multi-line expression one line at a time and the implementation needs to determine whether to wait for more input or to evaluate what has been entered so far.
Concretely, this returns true when every error present is caused by the parser reaching the end of the input before a construct was closed (e.g. an unclosed string, array, block, or keyword), and returns false when any error is caused by a token that makes the input structurally invalid regardless of what might follow (e.g. a stray end, ], or ) with no matching opener).
Examples:
Ruby::Prism.parse("1 + [").continuable? #=> true (unclosed array) Ruby::Prism.parse("1 + ]").continuable? #=> false (stray ]) Ruby::Prism.parse("tap do").continuable? #=> true (unclosed block) Ruby::Prism.parse("end.tap do").continuable? #=> false (stray end)
: () -> bool