Ruby String Integer Scanning
parsing, ruby, string
Solution
Multiple assignment from arrays can be useful for this
a,b,c,d = sc.split
b=b.to_i
d=d.to_i
A less efficient alternative:
a,b,c,d = sc.split.map{|w| Integer(w) rescue w}
Problem
Is there a Ruby equivalent of the Java Scanner? If I have a string like "hello 123 hi 234" In Java I could do ``` Scanner sc = new Scanner("hello 123 hi 234"); String a = sc.nextString(); int b = sc.nextInt(); String c = sc.nextString(); int d = sc.nextInt(); ``` How would you do this in Ruby?