Can anyone tell me why the first example uses braces and the second
example uses parentheses? Is it because 1st example is a hash literal,
second is not?
Do you mean in
u.attributes = {:name =>"Fred", :color => "green"}
Because that is assigning the hash to the variable u.attributes.
Please quote the previous message when replying in order to avoid the
necessity of looking back at previous emails to work out what the
message is referring to.
It's Ruby. If the last argument in a function call is a hash, you can
omit
the braces.
I think technically it has to do with ambiguity. It doesn't really have
anything do with it being the last argument, but rather omitting the
braces anywhere else in the argument list would cause ambiguity.
Although, that's really just semantics.