title: I need explanation of method inject
body: <p>I am trying to figure out how inject method works</p>
  
  <p>Can someone explain this </p>
  
  <pre><code>def mysort
    if djeca.any?
        djeca.order(name: :asc).inject([]) { |sum, c| sum += c.mysort}.uniq
    else
        [self]
  end
  </code></pre>
  
  <p><code>mysort</code> is method of model  class  <code>Books</code></p>
  
  <p>In controller I call method mysort : </p>
  
  <pre><code>@mybooks= Books.find_by(name: 'renesansa')
  @mybookss= @mybooks.leaf_wms
  </code></pre>