# encoding: utf-8
class Person
attr_reader :short_name
def initialize(short_name)
@short_name = short_name
end
def greeting_line
short_name = short_name.downcase
"Hello #{short_name}"
end
end
person = Person.new("MS. LEE")
puts person.short_name => "MS. LEE"
puts person.greeting_line => NoMethodError: undefined method `downcase' for nil:NilClass
The exception occurs at "short_name = short_name.downcase" since (short_name = short_name) makes short_name become nil.
Why is "short_name" on the right side is not getting the value from the instance method "short_name"?