Skip to content

Commit 2a03542

Browse files
refactor: use if elsif
1 parent 76b3dff commit 2a03542

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/iruby/backend.rb

+8-9
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,18 @@ def eval(code, store_history)
7373
raise SystemExit
7474
end
7575

76-
# not complete exception syntex error
77-
unless @pry.eval_string.empty?
76+
# Pry::Code.complete_expression? return false
77+
if !@pry.eval_string.empty?
7878
syntax_error = @pry.eval_string
7979
@pry.reset_eval_string
80-
@pry.evaluate_ruby syntax_error
81-
end
80+
@pry.evaluate_ruby(syntax_error)
8281

83-
# raise SyntaxError when check if it is complete exception
82+
# Pry::Code.complete_expression? raise SyntaxError
8483
# evaluate again for current line number
85-
if @pry.last_result_is_exception? &&
86-
@pry.last_exception.is_a?(SyntaxError) &&
87-
@pry.last_exception.is_a?(Pry::UserError)
88-
@pry.evaluate_ruby code
84+
elsif @pry.last_result_is_exception? &&
85+
@pry.last_exception.is_a?(SyntaxError) &&
86+
@pry.last_exception.is_a?(Pry::UserError)
87+
@pry.evaluate_ruby(code)
8988
end
9089

9190
raise @pry.last_exception if @pry.last_result_is_exception?

0 commit comments

Comments
 (0)