Pairing Ruby Operators
Given the following Ruby instructions:
(Reading input and storing each word in an array, removing spaces between words, etc.)
input = gets.chomp
inArr = []
input.strip.each (" ") { |w| inArr.push w }
inArr.delete_if {|ele| ele == " "}
inArr.each {|w| w.strip!}
I was wondering if anyone could suggest a way to optimize this code, perhaps by chaining or removing some unnecessary assertions, because I have a feeling that much less code can be done, but since I'm new to Ruby, for me, to see how :)
Thank,
RM
+1
source to share