by iamrohitbanga · 8y ago · 0 comments
e.g.
employees.flat_map(&:addresses).map(&:city).uniq.sort
# in place of
employees().flat_map(&:addresses).map(&:city).uniq().sort()“Attributes” in Ruby are just methods that do attribute-like things, so there is no ambiguity: it is always a method.
When used correctly you can write IMHO really clean and concise OOP code where (cascading) changes are easily made.
something = [ alpha beta, gamma ]
I have no idea if I just invoked alpha(beta, gamma) and put the result into a single-member array, or if I've got an array with two elements - alpha(beta) and gamma.