Created
April 7, 2022 17:16
-
-
Save trycf/eb5b7a0f97f4e7b4669a68c7ac3f49d7 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains 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
<cfscript> | |
array function f(required array a) { | |
local.setInFunction = true | |
local.remappedArray = a.map((v) => v, true, 5) | |
local.sortedArray = local.remappedArray.sort(sortHandler) | |
writeOutput("setInFunction should exist: " & local.keyExists("setInFunction") & "<br>") | |
writeOutput("setInSortCallBack should NOT exist: " & local.keyExists("setInSortCallBack") & "<br>") | |
writeDump(local) // all as one would expect when using a function defined by statement | |
return local.sortedArray | |
} | |
a = [4,3,2,1] | |
result = f(a) | |
writeDump(result) | |
function sortHandler(e1, e2) { | |
local.setInSortCallBack = true | |
return e2 - e1 | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment