On Jul 13, 10:18 am, Yorick Peterse <[email protected]> wrote:
> Jeremy,
>
> Ah, that makes sense. Though after having played with it it seems it's not
> very hard to detect whether or not the specified
> string is actually converted correctly:
>
> 'hello123'.to_f # => 0.0
> 'h'.to_f           # => 0.0
>
> Based on this you could do something like the following:
>
> input        = '12'
> converted = input.to_f
>
> if input !== '0.0' and converted === 0.0
>   raise(ArgumentError, '....')
> end

That falls down quickly.  What if input is '0.00'?

There's no point in doing a non-strict conversion and then checking
the input depending on the output.  If you want to have any strictness
at all, you should do a strict conversion.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to