# Why do do...end and curly braces behave differently with method arguments?

Source: https://poignantguide.net/answers/read/why-do-doend-and-curly-braces-behave-differently-with-method-arguments/
Site: Poignant Guide Ruby Q&A, category Blocks, procs and iterators
Published: 2026-11-29. Updated: 2026-11-30. Replies: 2.

## Question by Yara H., 2026-11-29

I was sure `do ... end` and `{ ... }` were two spellings of the same thing, like `begin/end` and braces in C. Then this happened in a script for my data structures course:

```ruby
numbers = [1, 2, 3]

puts numbers.map { |n| n * 2 }
puts numbers.map do |n| n * 2 end
```

Output on Ruby 3.3.4:

```
2
4
6
#<Enumerator: [1, 2, 3]:map>
```

The first line does what I expected. The second prints an Enumerator and the doubled numbers never appear. No error, no warning. The block is the same text, only the delimiters differ.

I know `map` without a block returns an Enumerator, so something is calling `map` with no block. But I wrote the block right next to it. Is this a parser quirk, or is it documented? And is there a rule for which one to use? I read the guide's chapter 4 and it uses both styles without explanation.

## Reply 1 by Kai N., 2026-11-30

They are identical, it is only style. Braces for one line, do/end for several. If you get the Enumerator, you probably have a typo somewhere else in the file, or the data is not what you think it is. Print `numbers` first.

## Reply 2 by Sunita R., 2026-11-30

Coming from Python, the thing I noticed is that Ruby lets you skip the parentheses on `puts`, and that is what causes the trouble. If you write `puts(numbers.map do |n| n * 2 end)` the output is 2, 4, 6 again. I would like to know if that is the recommended fix or only a workaround.

---
Cite as: Poignant Guide Ruby Q&A, "Why do do...end and curly braces behave differently with method arguments?", https://poignantguide.net/answers/read/why-do-doend-and-curly-braces-behave-differently-with-method-arguments/, accessed 2026-12-01.
