[ENH] String and Character conversion methods

Ned Konz ned at bike-nomad.com
Sat Jul 31 21:56:59 UTC 2004


On Wednesday 28 July 2004 9:49 pm, Cancerbero wrote:
> Hi. I don't know how formally make this kind of suggestions so excuse
> me if I'm doing it wrong.
>
> My situation is this: The user's input is a String representing a
> floating point number, so I want something that converts a String
> representing a floating point number to a Float. Example: Something like
> String>>asFloat so '3.14' asFloat returns the Float 3.14.
>
> So my suggesiont is to add a method String>>asFloat. For example:


What about

'3.14' asNumber => 3.14
'3' asNumber => 3

or if you really wanted to be sure:

'3.14' asNumber asFloat => 3.14
'3' asNumber asFloat => 3.0

-- 
Ned Konz
http://bike-nomad.com




More information about the Squeak-dev mailing list