error while reading a text file in ruby -


def read_file_info(*file_name)   arr = io.readlines(file_name)   puts arr end  read_file_info("abcd.txt") 

is giving me error in

readlines': no implicit conversion of array string (typeerror) 

*file_name means variable amount of parameters, need extract first parameter file_name[0], check other answer single parameter or use multiple files:

def read_file_info(*files)   files.each |file_name|     arr = io.readlines(file_name)     puts arr   end end  read_file_info("abcd.txt", "efgh.txt") 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -