From: shannonskipper@... Date: 2018-07-24T15:54:37+00:00 Subject: [ruby-core:88080] [Ruby trunk Bug#14935] Inconsitent behaviour with puts and enumerator with different block format. 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 # ��� ~ # 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: