Created
June 17, 2014 22:21
-
-
Save nicksteffens/e2a892d76098a7dc03e4 to your computer and use it in GitHub Desktop.
Coffee Returning Object from nested function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coffee returning nested function | |
# global variable | |
gVar = { success: true } | |
# return the modified object from global function | |
gFunc = (obj) -> | |
# local var | |
lVar = obj | |
# nested function for conditional | |
nestedFunc = (obj) -> | |
if !obj.success | |
obj.success = true | |
obj.attr = "success is now true" | |
else | |
obj.attr = "success was already true" | |
obj | |
# log the return of the nested function | |
console.log nestedFunc(lVar) | |
# call globalFunction | |
gFunc(gVar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment