Closed ankane closed 3 years ago
In my case, if I don't want it to output, I often put a 0
in the last line. However, I'm neutral on this matter because I don't really care about it. If more people want to change it, it should be changed. What do you think, @mrkn, the owner?
I have a plan to implement the output prevention by putting single semicolon at the end of the cell. It is the same behavior as IJulia.
I found a very interesting issue on IJulia, the kernel of the Julia language. https://github.com/JuliaLang/IJulia.jl/issues/649
In IPython, something like x = np.arange(1000) shows no output, whereas in IJulia x = collect(1:1000) does. I understand this matches the REPL, but is there a way to surpress this by default other than adding semicolons everywhere?
No. When you evaluate a cell in IJulia, it is just returns the value of the last expression, and what you are seeing here is a difference between the Julia and Python languages. In Python, assignment expressions don't have a value, whereas in Julia the assignment x = y has the value y.
In Python and R, assignment expressions do not have a value, but in Julia and Ruby, assignment expressions have a value, so it is more natural to show the value.However, even in the Julia language, there seems to be an argument that the output should be hidden for usability. I was thinking of merging this pull request, but after seeing Julia's policy, I decided to put it on hold again.
By the way, I want to merge this if this behavior can be opt-in by a configuration like below.
IRuby.silent_assignment = true
@ankane Could you make this configurable? The default configuration should be disable for compatibility.
I agree with the semicolon!
In Julia and Ruby, an assignment is an expression so it has a value, whereas an assignment in Python isn't an expression but a statement so it doesn't have a value.
Added an option and made it opt-in.
@ankane Thank you so much!
That was fast 🔥 Thanks @mrkn and @kojix2!
Hi, this PR hides output on assignment (like Python). This avoids the need to add
; nil
to lines. It uses assignment_expression? from IRB and checks that it exists first for older versions (added in https://github.com/ruby/irb/commit/0a3a0f5d9ed543440950dfc2a4ad2ec32e66009e).Ref: #195