Actions
Feature #16432
closedUsing `_1` inside `binding.irb` will cause unintended behavior
Status:
Closed
Assignee:
-
Target version:
-
Description
Summary¶
Calling binding.irb
in a block that uses _1
and using _1
in irb
will cause unintended behavior.
Steps to reproduce¶
- Use
_1
in block - Use
binding.irb
in block - Use block with
_1
inbinding.irb
# test.rb
proc {
binding.irb
_1
}.call 42
# binding.irb
irb> (1..10).map { _1 + _1 }
Expected behavior¶
irb> _1
=> 42
irb> (1..10).map { _1 + _1 }
= > [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
Actual behavior¶
- Refers to the
_1
of the block that calledbinding.irb
irb> _1
=> 42
irb> (1..10).map { _1 + _1 }
= > [84, 84, 84, 84, 84, 84, 84, 84, 84, 84]
I think this is an unintended behavior for the user.
Actions
Like0
Like0Like0Like0Like0Like0