i'm learning ruby using tdd (test driven development). in rspec code, see:
it "return sum of 2 different arugments" calc = calculator.new expect(calc.add(1,2)).to eq(3) end often, in other languages, last command written eq (expect(calc(1,2)), 3) or expect(calc.add(1,2)).eq(3).
but in example, there nothing connecting first phrase expect(calc.add(1,2)) , second phrase eq(3).
so in ruby, name of grammar?
it pair of parentheses around arguments can omitted.
expect(calc.add(1, 2)).to eq(3) is syntax sugared form of:
expect(calc.add(1, 2)).to(eq(3)) that is, eq(3) argument of method to.
according @digitalross, seems called poetry mode.
Comments
Post a Comment