by Zak · 8y ago · 0 comments
Because Ruby doesn't automatically coerce arbitrary types to numbers when you try to perform arithmetic on them. This is a Good Thing.
2 * "4"
> TypeError 2 * "4".to_i
> 8Interestingly, it is possible to multiply a string by a number, but no coercion takes place.
"2" * 4
> "2222"I think implicit coercion is bad, but that's a separate issue from null.