Integer to Array

x=3D1234
y=3Dx.to_s.scan(\/d\)

or
y=3Dx.to_s.split(//)

or
y=3Dx.to_s.split('')


Array to integer

z=3Dy.to_s.to_i


Thanks and Regards,
 
Lokesh Agrawal
Software Engineer

----------------------------------------------------------------------------
----------
"Dream is not what you see in sleep, is the the thing which does not let you
sleep"
----------------------------------------------------------------------------
----------

-----Original Message-----
From: Pe=F1a, Botp [mailto:botp / delmonte-phil.com] 
Sent: Monday, May 12, 2008 2:19 PM
To: ruby-talk ML
Subject: Re: Convert integer to array?

From: kaepora / mac.com [mailto:kaepora / mac.com] 
# Let's say I have: x=3D1234
# How can I convert that to the follow array: x=3D[1, 2, 3, 4]

irb is friendly, just play w it..

"1234".split(//)
#=3D> ["1", "2", "3", "4"]

your next task is to convert those into integers, then you're good to go..

kind regards -botp


DISCLAIMER=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
This e-mail may contain privileged and confidential information which is the=
 property of Persistent Systems Ltd. It is intended only for the use of the=
 individual or entity to which it is addressed. If you are not the intended=
 recipient, you are not authorized to read, retain, copy, print, distribute=
 or use this message. If you have received this communication in error, plea=
se notify the sender and delete all copies of this message. Persistent Syste=
ms Ltd. does not accept any liability for virus infected mails.