Converting text to an integer

10 views
Skip to first unread message

Sam Aaron

unread,
Mar 16, 2010, 5:41:42 PM3/16/10
to ioke-l...@googlegroups.com
Hi there,

if I'm reading text representing a numeric integer from the program arguments, what's the best way to convert it to an integer?

The closest I can get to this is to convert it to a decimal value:

System programArguments first toDecimal

Thanks,

Sam

---
http://sam.aaron.name

Ola Bini

unread,
Mar 16, 2010, 5:56:43 PM3/16/10
to ioke-l...@googlegroups.com, Sam Aaron
On 2010-03-16 16.41, Sam Aaron wrote:
> Hi there,
>
> if I'm reading text representing a numeric integer from the program arguments, what's the best way to convert it to an integer?
>
> The closest I can get to this is to convert it to a decimal value:
>
> System programArguments first toDecimal
>

Just for posterity:
At the moment you achieve this using toRational. I've been meaning to
possibly change the name of this conversion method though - so we'll see.

Cheers
--
Ola Bini (http://olabini.com)
Ioke - JRuby - ThoughtWorks

"Yields falsehood when quined" yields falsehood when quined.

Reply all
Reply to author
Forward
0 new messages