Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/a14e90f6775e943be73d643a1f44ef07 to your computer and use it in GitHub Desktop.
Save trycf/a14e90f6775e943be73d643a1f44ef07 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
array function f(required array a) {
local.setInFunction = true
local.remappedArray = a.map((v) => v, true, 5)
local.sortedArray = local.remappedArray.sort((e1, e2) => {
local.setInSortCallBack = true
return e2 - e1
})
writeOutput("setInFunction should exist: " & local.keyExists("setInFunction") & "<br>") // CF returns false
writeOutput("setInSortCallBack should NOT exist: " & local.keyExists("setInSortCallBack") & "<br>") // CF returns true
writeDump(local) // it's the local from the sort callback, not this function!
return local.sortedArray
}
a = [4,3,2,1]
result = f(a)
writeDump(result)
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment