Histogram .split and .split(" ")



what is the difference between using .spit and .split with parenthesis [ .split(" ") ]. is it aproblem if i use .split with parenthesis inlcuding what key im using to split them? "space" or "/" or "-''

puts "Please type the statement here...!"
text = gets.chomp

words = text.split

frequencies = Hash.new(0)
words.each do { |word| frequencies[word] += 1 }


When no argument is included, Ruby defaults to a space delimiter. There are lots of ways to use the method.



ohh i see. so that means i can only include argument only if "separator" is "/ "or "-" etc

e.g date = 12/12/16
num = date.split("/")

Thanks for the link (y).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.