Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide output on assignment #312

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/iruby/backend.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module IRuby
In, Out = [nil], [nil]

class << self
attr_accessor :silent_assignment
end
self.silent_assignment = false

module History
def eval(code, store_history)
b = eval_binding
Expand Down Expand Up @@ -53,7 +58,7 @@ def eval_binding

def eval(code, store_history)
@irb.context.evaluate(code, 0)
@irb.context.last_value
@irb.context.last_value unless IRuby.silent_assignment && assignment_expression?(code)
end

def complete(code)
Expand All @@ -69,6 +74,10 @@ def init_main_object(main)
wrapper_module.include(*args)
end
end

def assignment_expression?(code)
@irb.respond_to?(:assignment_expression?) && @irb.assignment_expression?(code)
end
end

class PryBackend
Expand Down