class String def pop return nil if self.empty? item=self[-1] self.chop! return nil if item.nil? item.chr endenda = "this is a test"puts a.pop