Skip to content

Instantly share code, notes, and snippets.

@strika
Created August 27, 2013 07:36
Show Gist options
  • Save strika/6350713 to your computer and use it in GitHub Desktop.
Save strika/6350713 to your computer and use it in GitHub Desktop.
class NullObject
def nil?; true; end
def !; true end
def to_a; []; end
def to_s(*args); ""; end
def to_str(*args); ""; end
def to_f(*args); 0.0; end
def to_i(*args); 0; end
def method_missing(*args, &blk)
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment