To display a nil value using print or puts, Ruby 1.8 displays "nil," whereas Ruby 1.9 displays an empty string.
To be sure that the string representation of nil is displayed, use p or the inspect method instead of print.
You may also display its class since nil is an instance of NilClass or test whether it is nil using the nil? method:
arr = ['a', 'b', 'c'] puts(arr[3].inspect) #=> nil puts(arr[3].class) #=> NilClass p(arr[3]) #=> nil puts(arr[3].nil?) #=> true # from w ww . ja v a 2s. co m