Histogram .split and .split(" ")


#1

https://www.codecademy.com/pt/courses/ruby-beginner-en-693PD/0/5?curriculum_id=5059f8619189a5000201fbcb

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 }


#2

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

https://www.dotnetperls.com/split-ruby


#3

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).


#4

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