[Solved] How to convert a string to an array in Ruby [closed]


You can use json to convert it to an array.

class T
  require 'json'
  def array_detect(array_string)
    begin
      json = JSON.parse array_string
      if json.is_a? Array
        # is an array
      else
        # not an array
      end
    rescue JSON::ParserError => e
      puts e.message
      # not a valid json string
    end
  end
end

solved How to convert a string to an array in Ruby [closed]