--
--
Você recebeu essa mensagem porquê está inscrito no Google
Groups "rails-br".
Para enviar uma mensagem para o grupo, mande um email para rail...@googlegroups.com
Para se descadastrar, mande um e-mail para
rails-br+u...@googlegroups.com
Visite o grupo em http://groups.google.com/group/rails-br?hl=pt-BR
Leia nossa política de uso: http://goo.gl/YGgt7
---
Você está recebendo esta mensagem porque se inscreveu no grupo "rails-br" dos Grupos do Google.
Para cancelar a inscrição neste grupo e parar de receber seus e-mails, envie um e-mail para rails-br+u...@googlegroups.com.
Para obter mais opções, acesse https://groups.google.com/groups/opt_out.
--
# find the longest word longest = %w{ cat sheep bear }.inject do |memo,word| memo.length > word.length ? memo : word end longest #=> "sheep"
--
reduce e inject são o mesmo método2013/3/1 Ivan Joaquim (Pichot) <pich...@gmail.com>
No link que o Celso enviou ( http://railspikes.com/2008/8/11/understanding-map-and-reduce ) , está dizendo que é melhor usar o 'reduce' ao 'inject'.
Legal a thread, não conhecia nenhum desses métodos, era tudo na base do '.each'.O que acham? exites diferenças entre os dois?
2013/3/1 Alex Takitani <atp...@gmail.com>Não faz só somaCombines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator.
In mathematics, a binary operation on a set is a calculation involving two elements of the set (called operands) and producing another element of the set (more formally, anoperation whose arity is two). Examples include the familiar elementary arithmetic operations of addition, subtraction, multiplication and division. Other examples are readily found in different areas of mathematics, for example, vector addition,