Why the following code issues an error ?
[\'hello\',\'stack\',\'overflow\'].inject{|memo,s|memo+s.length} TypeError: can\'t convert Fixnum into String
You have the answer in apidock :
If you do not explicitly specify an initial value for memo, then uses the first element of collection is used as the initial value of memo.
That is, without an initial value, you're trying to do 'hello' + 'stack'.length
'hello' + 'stack'.length