9 digits in a string "123456789", convert to individual Fixnums
[1,2,3,4,5,6,7,8,9], or as below
a, b, c, d, e, f, g, h, i = id.scan(/\d/).map(&:to_i)
Simpler yet how about ["1", "2", ...]. Is scan the only direct way?
I tried the "*" mechanism, no such luck, and tried array slicing again
no luck. TIA
(1..9).to_a
?
I'm not quite sure what you are trying to do, you see Are you trying
to actaully set variables? If you are, first I'd ask "why are you trying
to set a range of instance variables". After that, if you're sure you do
(and hell, "for fun" is an answer), then I'm sure that there is a method
like instance_variable_set, only for manipulating local variables, but
oddly, I don't seem able to find it at the moment...
which is great, but if we are golfing let us improve our handicap
id.unpack("c*")....
Robert
···
On 10/18/06, Mike Dvorkin <mike@rubywizards.com> wrote:
id.unpack('c' * id.size).map { |x| x-48 } # without regex and to_i
conversions
--
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.