Guest User

Untitled

a guest
Jan 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.16 KB | None | 0 0
  1. def count_words(string)
  2.   hash = {}
  3.   array = string.downcase.gsub(/\W/,’ ‘).split
  4.   array.uniq.each { |i| hash [i] = array.count(i) }
  5.   puts hash
  6. end
Add Comment
Please, Sign In to add comment