Being from c programming background, to get an array of some property from the objects, I used to write this in Ruby:
amount_array = []
for order in account.orders
amount_array << order.amount.some_operation
end
While a much cleaner way is to use Array#collect:
amount_array = account.orders.collect { |order| order.amount.some_operation }
This tip was submitted by zerothabhishek.
You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.