[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Make sure numbers are numbers
- From: Henk Boom <henk@...>
- Date: Thu, 15 Apr 2010 23:07:21 -0400
I just fixed a subtle bug in my serialization/deserialization
functions for a data structure, where objects that were serialized
then deserialized looked identical but behaved slightly differently.
It was caused by something like this:
> return 9 < 10
> return "9" < "10"
Lesson learned: make sure to use tonumber() on numbers you extract
It also boost the importance of frequent type checking in my mind, and
makes me hate automatic string->number coercion a little bit more :p