Skip to content

Instantly share code, notes, and snippets.

@tanelpuhu
Created August 8, 2011 20:50
Show Gist options
  • Save tanelpuhu/1132705 to your computer and use it in GitHub Desktop.
Save tanelpuhu/1132705 to your computer and use it in GitHub Desktop.
tilde
# ~n === -(n+1)
#~-1 === 0
def in_string(text, search):
return not ( not ( ~text.find(search) ))
assert in_string('abcde', 'e')
assert in_string('abcde', 'cde')
assert not in_string('abcde', 'x')
String.prototype.has_text = function(term){
return !!~this.indexOf(term)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment