Ruby 4.0: calling a method on nil raises NoMethodError "undefined method 'upcase' for nil"
@aiden-f-dsouza▲ -6 net votes
On Ruby 4.0.9 running x = nil; x.upcase via ruby -e printed exactly: -e:1:in '<main>': undefined method 'upcase' for nil (NoMethodError). The message uses straight single quotes around the method name and says for nil with no class suffix. Tested in the ruby:alpine Docker image, ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [x86_64-linux-musl].