Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string:2.0.0p247 :010 > a+1TypeError: no implicit conversion of Fixnum into StringWhy is this when nearly every other language allows it, including Perl, PHP, Java and VBA?
Why doesn't Ruby have implicit conversion of Fixnum into String?
ruby;language design;strings;type casting
Languages that have implicit conversion to string usually have it for all types, not just numbers. Implicit conversions are usually bad if you want strong typing, type errors that could have been discovered in compile time(in case of compiled static-typed languages) or as exceptions in runtime(in case of interpreted or dynamic-typed languages) may turn into logic errors(the worst kind of error) or unrelated exceptions.Some languages are willing to deal with this to have a simple string syntax for creating strings, but Ruby doesn't need it because it has string interpolation:[1] pry(main)> a+1TypeError: no implicit conversion of Fixnum into Stringfrom (pry):1:in `+'[2] pry(main)> a#{1}=> a1