Issue #14935 has been updated by shan (Shannon Skipper).
#puts returns `nil`, so when you're mapping you end up with `[nil, nil, nil]`, which prints with #puts as three blank lines. If you use `p` instead of `puts` inside the block, the block will return `i` instead of `nil` and you'll see the same output.
----------------------------------------
Bug #14935: Inconsitent behaviour with puts and enumerator with different block format.
https://bugs.ruby-lang.org/issues/14935#change-73103
* Author: puneet.sutar / gmail.com (Puneet Sutar)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
### Case: 1
```
~ ruby
puts [1,2,3].map do |i|
puts i
end
#<Enumerator:0x007ffe930b76d0>
~
# block does get evaluated.
```
Case 2:
```
~ ruby
puts [1, 2, 3].map { |i| puts i }
1
2
3
~
# Block gets evaluated.
```
My question is Shouldn't both cases give consistent output.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>