Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
Alifatisk
· 2y ago · 0 comments
Regarding the Ruby example, why did they use Float("...") instead of #to_f?
Comments
[–]
intelekshual
2y ago
Probably because `Float()` is stricter and will raise an error if the string isn't a valid number, whereas `#to_f` will silently return 0.0 or do a best-effort conversion (e.g. "1.2abc".to_f => 1.2)
[–]
Alifatisk
OP
2y ago
Ohhh!