0

I'm trying to use the <% provide (:title, 'home') %> but a syntax error is returned. should I install a gem for it to work. Thanks in advance

Maxime Rouiller
  • 13,614
  • 9
  • 57
  • 107
Vic Turuthi
  • 5
  • 1
  • 4

1 Answers1

2

In Ruby the parens around a method call are optional:

provide :title, 'home'

But when using parens there should not be space between the method name and the parens:

def add(args*)
  args.sum
end

add 1, 2 # => 3
add(1,2) # => 3 
add (1,2) # syntax error, unexpected ',', expecting ')'
add (1+2), (1+2) # => 6

In the last examples you can see that Ruby treats the parens as a single argument when there is a space - which is why it gives a syntax error.

max
  • 96,212
  • 14
  • 104
  • 165