Trolling in Ruby - Implementing JavaScript-like Maths With Implicit Conversion Hijack
If you’ve ever worked with JavaScript, especially in pre-SPA/pre-frameworks era with just jQuery, you probably had a chance to see an “exotic” maths in action that looks similar to this:
"3" + 4
// => "34"
That kind of behavior usually comes as a big surprise and due to that fact, JavaScript has gotten some bad reputation (even though there is a rationale behind it). If we tried that in Ruby, we would get an obvious TypeError
:
"3" + 4
# => TypeError (no implicit conversion of Integer into String)
Would it be possible though to obtain the same result somehow in Ruby?
Post a comment