Ruby is type unsafe language but it goes a step further and avoids checking dynamically too.
Consider this code
x = :abc if x == 'abc' puts "Symbol and String are two different classes" else puts x.class, 'abc'.class end # puts can print a symbol and string alike. puts x
- I’m new to Ruby. How could Ruby let a
Stringcompare, in spite of being aware of their types? Like Python, it can throw an error.
- How can
Symbolas good as a String