Skip to content

Instantly share code, notes, and snippets.

@Jberlinsky
Created December 21, 2014 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jberlinsky/64e4cbeca33d65470120 to your computer and use it in GitHub Desktop.
Save Jberlinsky/64e4cbeca33d65470120 to your computer and use it in GitHub Desktop.
Null Object Pattern Example
class NullNumber
def +(other)
raise ArgumentError
end
def to_i
raise ArgumentError
end
end
assert_nothing_raised do
1 + 1
end
assert_raise ArgumentError do
NullNumber.new + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment