Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class String
- @@alphabet = ('a'..'z').entries.join('')
- def sum
- letters = split('')
- letters.inject(0) do |sum, letter|
- if (i = @@alphabet.index(letter))
- # puts "#{letter} = #{i}" # Uncommenting this line works
- # sum += i # ...but uncommenting this line doesn't
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment