In comparison to converting an integer to string, converting number-like strings to an integer is more economical memory-allocation-wise because Ruby integers are fixed entities.
In other words, while 3.to_s.object_idwill always be different, "3".to_i.object_idwill always be the same.
In comparison to converting an integer to string, converting number-like strings to an integer is more economical memory-allocation-wise because Ruby integers are fixed entities.
In other words, while
3.to_s.object_id
will always be different,"3".to_i.object_id
will always be the same.