Ruby Inject

Weird behavior of inject() method in Ruby: Produces: "applesorangesbananas" # Correct ["applesorangesbananas", "oranges", "bananas"] # Wrong Why did it modify the original array? The inject should only be working on str. To produce the desired result, I had to replace the inject() with inject(""). But works correctly, as you'd expect it to, when using an... Continue Reading →


Blog at

Up ↑