+ 4
This is because you are calling .index() on an array which only contains letters from lowercase 'a' till lowercase 'z', that is, the array does not have uppercase letters. Passing a letter to arrayofnums.index() that is not present in arrayofnums (like an uppercase letter) will return `nil`. When you use the + operator on nil, it gives error. `word.downcase` does not work for you because the `String.downcase` method does NOT make changes to the original string, it instead *returns the downcased string*. Change the line 4 to `word = word.downcase` OR `word.downcase!`
16th Feb 2021, 3:50 PM
XXX
XXX - avatar