4

When I try to do

assert_equal { dry: true }, res

I get

syntax error, unexpected ':', expecting '}'

        assert_equal { dry: true }, res

but

assert_equal({ dry: true }, res)

works fine. Why is first form not sufficient for ruby to understand what I mean? Or to be more precise, what does Ruby think I'm trying to do?

Sagar Pandya
  • 9,323
  • 2
  • 24
  • 35
graywolf
  • 7,092
  • 7
  • 53
  • 77

1 Answers1

3

In the first example, the curly braces are interpreted as delimiting a block. Since dry: true is not a legal expression, you get a SyntaxError.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653