2 ms·
Party time with Ruby: orders.map(&:total) ... Where :total is a symbol, and & is asking :total for the Proc version of itself (a Proc being an anonymous fun
by damncabbage 14y ago
Party time with Ruby:
orders.map(&:total)
... Where :total is a symbol, and & is asking :total for the Proc version of itself (a Proc being an anonymous function of sorts), and map is then calling that Proc with a single argument (an order from the list of orders).
More detail: http://stackoverflow.com/a/1217114/3528 http://stackoverflow.com/a/1217114/3528