Ruby statement chaining

Given following Ruby statements:

(Read input and store each word in 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 can suggest a way to optimize this code, maybe via chaining or removing some unneeded statements, because i have a feeling this can be done in much less code, but since I'm new to Ruby its hard for me to see how :)




gets.split should get you what you want

>> gets.split
this is a test
=> ["this", "is", "a", "test"]

Need Your Help

How to run a express.js reverse proxy using grunt

node.js express gruntjs

I used express JS to create a reverse proxy. Basically, it forwards any API request to a python server.