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

html5 boilerplate doesn't include reset.css?

css reset html5boilerplate normalize

I am using HTML5 Boilerplate and don't find any reset style. All H1 elements has 50px of margin top and bottom :S

What JVM-based scripting language support @WebService to create services at runtime?

java web-services scripting jvm jsr223

I am at a situation where I need to be able to create and expose a webservice at run time. (i.e. no "javac"-compilation step).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.