ruby - Codefights No implicit conversion of String into Integer -


here code:

def alllongeststrings(inputarray)     array = array.new     inputarray.each |i|         if inputarray[i].length == inputarray.max.length             array << inputarray[i]         end     end     return array end  inputarray = ["aba", "aa", "ad", "vcd", "aba"] 

it says "no implicit conversion of string integer" , can't figure out. doing wrong?

error here:

if i.length == inputarray.max.length # instead of inputarray[i]   array << end 

but suggest use select:

input_array = ["aba", "aa", "ad", "vcd", "aba"] max_length = input_array.max.length input_array.select { |el| el.length == max_length } #=> ["aba", "vcd", "aba"] 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -