Skip to content

Instantly share code, notes, and snippets.

@nicksteffens
Created June 17, 2014 22:21
Show Gist options
  • Save nicksteffens/e2a892d76098a7dc03e4 to your computer and use it in GitHub Desktop.
Save nicksteffens/e2a892d76098a7dc03e4 to your computer and use it in GitHub Desktop.
Coffee Returning Object from nested function
# 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