P
P
Pavel Shcheglov2016-03-27 16:50:32
ruby
Pavel Shcheglov, 2016-03-27 16:50:32

How to collect and return an array in ruby?

Hello. How can this be rewritten better? (remove array variables)
I'm sorry, gentlemen. Asked the wrong question.

def foo
  array ||= []

  @array_datas.each do |array_data|
    array_data.each do |data|
      array << data + 1
    end
  end

  array
end

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question