Hi! I'm Nathan Hoad

Ruby and syntactic sugar

While having a chat with Keith about the meaning of the term 'syntactic sugar', he pointed out that my examples weren't strictly that. The methods times and each for numbers and arrays aren't technically syntax of Ruby, just things you can do with Ruby.

A more accurate example of 'syntactic sugar' would be something like this:

# this:
blah = Blah.new({:arg1 => 'something', :thing => 'something else'})
# could be written like this:
blah = Blah.new :arg1 => 'something', :thing => 'something else'

Braces and parenthesis are generally optional for method arguments and are normally only used to resolve which argument belongs to which method when passing methods as arguments to other methods. The syntax is so much cleaner when not having to include operators where their use is unnecessary.

If I just made your day a little better then thank me with a coffee or maybe a a pizza