masterslowpoke

Untitled

Aug 6th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.52 KB | None | 0 0
  1. require 'sinatra'
  2.  
  3. def stringify_array(arr)
  4.   return "not an array" unless arr.is_a? Array
  5.   return arr.join("$").split("$")
  6. end
  7.  
  8. get '/' do
  9.   "<pre>
  10.  Using a combination of Array’s join method and String’s split method, write a line of code that converts [1,2,3] into [\"1\", \"2\", \"3\"].
  11.  ANSWER
  12.  
  13.  def stringify_array(array)
  14.    return \"not an array\" unless arr.is_a? Array
  15.     return arr.join('$').split('$')
  16.  end
  17.  
  18.  stringify_array([1,2,3,4,5,6,7,8]) = #{stringify_array([1,2,3,4,5,6,7,8])}
  19.  </pre>"
  20. end
Advertisement
Add Comment
Please, Sign In to add comment