Skip to content

Instantly share code, notes, and snippets.

@P-Seebauer
Created December 4, 2014 12:25
Show Gist options
  • Save P-Seebauer/904b66d4ef9fca51d207 to your computer and use it in GitHub Desktop.
Save P-Seebauer/904b66d4ef9fca51d207 to your computer and use it in GitHub Desktop.
fluendo checking for method existence
# somewhere
extendMaybe = (classObjs...) ->
for classObj in classObjs
(methodName, method) -> classObj::[methodName] = method unless classObj::[methodName]?
# top of your file:
[extend] = extendMaybe String
# usage:
extend "append", (stringToAppend)-> @ + if stringToAppend then stringToAppend else ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment