Hacker News new | ask | show | jobs
by smitherfield 3181 days ago
I prefer Ruby's syntax too, but Swift also has a shorthand version which is, IMO, usually nicer.

  groceriesByDepartment.mapValues { $0.count }
2 comments

stuff like this always makes me miss Ruby's even-shorter-hand version though :)

  groceriesByDepartment.mapValues(&:count)  # not ruby, but meh
The shorthand version doesn‘t let you specify argumen types (only works when they can be inferred)
Which is vast majority of cases. Unless you work with a lot of legacy ObjC code.