nilin an object (a single instance of the class
NilClass) so methods can be called on it.
nil?is a standard method in Ruby that can be called on all objects and returns
falsefor anything else.
empty?is a standard Ruby method on some objects like Arrays, Hashes and Strings. Its exact behaviour will depend on the specific object, but typically it returns
trueif the object contains no elements.
blank?is not a standard Ruby method but is added to all objects by Rails and returns
false, empty, or a whitespace string.
nil.nil? => true false.nil? => false 1.nil? => false 0.nil? => false "".nil? => false .nil? => false "".empty? => true "abc".empty? => false .empty? => true [1, 2, 3].empty? => false 1.empty? => NoMethodError