Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created August 4, 2009 00:41
Show Gist options
  • Select an option

  • Save ELLIOTTCABLE/160949 to your computer and use it in GitHub Desktop.

Select an option

Save ELLIOTTCABLE/160949 to your computer and use it in GitHub Desktop.
##
# Inverts a `Check`, causing it to treat success as failure and failure as
# success.
def !
p "! called on #{self}"
p @lambda
p @lambda.call
old_lambda = @lambda
new_lambda = ->{value = old_lambda.call; p value; !value}
p new_lambda
p new_lambda.call
@lambda = new_lambda
p @lambda
p @lambda.call
end
"! called on #<Speck::Check:0x000001009e6a28>"
#<Proc:0x000001009e6a50@/Users/elliottcable/Code/speck/lib/speck/core_ext/check_mixins.rb:40 (lambda)>
false
#<Proc:0x000001009e6a50@/Users/elliottcable/Code/speck/lib/speck/core_ext/check_mixins.rb:40 (lambda)>
false
#<Proc:0x000001009e6a50@/Users/elliottcable/Code/speck/lib/speck/core_ext/check_mixins.rb:40 (lambda)>
false
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment